Re: [PHP-DB] viewing search result

2004-01-06 Thread Bossek
you can use PEAR DB::Pager
http://pear.php.net/package/DB_Pager

Fedde Van Feggelen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 str_replace(' ','%',$searchwords);
 
 $query=select * from table where colom like '%$searchwords%'  order by
id
 desc ;
 $result=mysql_query($query);
 $numresult=mysql_num_rows($result);


 Use limit in your select statement.

 laters,

 Fedde

 ~=There's a fine line between genius and insanity. I have erased this
line=~

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: SQL WHERE datetime NOW

2004-01-06 Thread John
John Dillon [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 ...WHERE TO_DAYS(NOW())+1TO_DAYS(MyTable.MyField) ORDER BY
MyTable.MyField DESC LIMIT 30;

 however, the LIMIT seems to apply before the ORDER BY clause.  How can I
get the LIMIT to apply after
 the ORDER BY?



On further reading, it appears LIMIT stops the query running once x number
of records are retrieved without sorting the whole table first.

Is there a function to get the top x number of results, as there is in MS
Access? Eg search on an auto-increment and get the last 10 records added?
(They don't always appear at the end of the table, I think if I am editing
the table they can appear after the currently active record.)

Regards,

John

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: SQL WHERE datetime NOW

2004-01-06 Thread Richard Davey
Hello John,

Tuesday, January 6, 2004, 5:20:22 PM, you wrote:

J On further reading, it appears LIMIT stops the query running once x number
J of records are retrieved without sorting the whole table first.

Where did you read this?

If you profile your query you'll notice that in say a 10,000 record
table, if you LIMIT 0,50 but order by something generic (say an ID or
date stamp) it'll still order all 10,000 records before returning the
50 you asked for.

(One of the main reasons I rarely use LIMIT)

J Is there a function to get the top x number of results, as there is in MS
J Access? Eg search on an auto-increment and get the last 10 records added?

LIMIT 50,-1

Retrieve from row 50 to last.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: SQL WHERE datetime NOW

2004-01-06 Thread John
Richard Davey [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello John,

 Tuesday, January 6, 2004, 5:20:22 PM, you wrote:

 J On further reading, it appears LIMIT stops the query running once x
number
 J of records are retrieved without sorting the whole table first.

 Where did you read this?

http://www.mysql.com/doc/en/LIMIT_optimisation.html
If you use LIMIT row_count with ORDER BY, MySQL will end the sorting as soon
as it has found the first row_count lines instead of sorting the whole
table.


 If you profile your query you'll notice that in say a 10,000 record
 table, if you LIMIT 0,50 but order by something generic (say an ID or
 date stamp) it'll still order all 10,000 records before returning the
 50 you asked for.


Does it?

 (One of the main reasons I rarely use LIMIT)

 J Is there a function to get the top x number of results, as there is in
MS
 J Access? Eg search on an auto-increment and get the last 10 records
added?

 LIMIT 50,-1

 Retrieve from row 50 to last.

I meant to largest 10 values in a column.  For example, I have a record with
ID number 1800 in an auto increment field, table has 1805 records.  When I
view the table 'raw' record 1800 appears after record 12.  I wanted records
1755-1805.  Instead now I've retrieved the whole table with ORDER BY without
LIMIT and put my start and end values in the for () loop.  Now, my eyes may
have deceived me...

Cheers,

John

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] unable to use mysqli (with mysql 5.0.0) for php5.0.0b3 - WinXP, IIS

2004-01-06 Thread Kostyantyn Zuzik
I can't run mysqli.

Please help me how can I install mysqli.

According to the Manual I copy C:\mysql\bin\libmySQL.dll (916Kb) to 
c:\windows and to c:\windows\system32.

(I've also tried to copy dll from C:\php\dlls\libmySQL.dll (228Kb))

when I run a simple script (WinXP, IIS):

?
$link= mysqli_connect(localhost, root, , mysql);
?
I get the following error:

Fatal error: Call to undefined function mysqli_connect() in
c:\Inetpub\wwwroot\index.php on line 2
Please tell me how can I succesfully install mysqli ?

_
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] LOCK TABLES with registry?

2004-01-06 Thread ma
Hi folks!

I use a registry in my webapp which holds an instance of my sql-class.
within my application i _only_ use this instance to do queries.

first of all i lock all my tables with

LOCK TABLES tableName WRITE;

Later in the progrmm i try to do a SELECT `menue` as `first` ... but i
get:
Table 'first' was not locked with LOCK TABLES


what do i do wrong?

# die welt ist schnell geworden...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] viewing search result

2004-01-06 Thread Hadi
Hi,
Iam new in this , can you tell me how to make the pager.php works? I can't
use it...


Best Regards,
Hadi Tjen



Bossek [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 you can use PEAR DB::Pager
 http://pear.php.net/package/DB_Pager

 Fedde Van Feggelen [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
  str_replace(' ','%',$searchwords);
  
  $query=select * from table where colom like '%$searchwords%'  order by
 id
  desc ;
  $result=mysql_query($query);
  $numresult=mysql_num_rows($result);
 
 
  Use limit in your select statement.
 
  laters,
 
  Fedde
 
  ~=There's a fine line between genius and insanity. I have erased this
 line=~

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] INSERT into mysql from dynamic drop down

2004-01-06 Thread irinchiang

Hi all, 

   Right now i would like to INSERT the values from a dynamic drop down 
menu into mysql database but encountered some problem here. Values in the drop 
down menu are retrieved from DB as follows:

SNIP

SELECT NAME=tutor_name CLASS=textarea
?


$sql = mysql_query(SELECT DISTINCT tutor_name FROM tutor);
while ($row = mysql_fetch_array($sql))
{
 print OPTION VALUE=\$tutor_name\  .$row[tutor_name]. /option;
 }
$result = $db-query($sql);

?
/SELECT

/SNIP

---

echo $_POST[tutor_name];

INSERT statement:

$sql = INSERT INTO class (class_code, tutor_name, edu_level, timetable_day, 
timetable_time)
VALUES 
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time');

---

I am trying to POST the values and then INSERT into DB but was not able to do 
so(all other values eg. class_code, edu_level etc...was able to be 
INSERTED into DB but not tutor_name. So, how do i insert values into DB from 
a dynamic drop down and where have i gone wrong???Hope to get some help real 
soon.=)

All help are greatly appreciated. Thanks in advance.


Regards, 
Irin. 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php