[PHP] Looking for pointers to mysql functions
I'm building a search function and I think most of the search part is solid. Now I'm trying to figure out the results part. Since my results would return about 7 fields per record, I'm thinking mysql_fetch_row over mysql results works better ? But I don't want every field from the row returned, only specific ones. Also, I want to allow for all records that meet criteria to be returned, and will set up a user variable, so they can choose how many records per page come back. Can anyone share some ideas or pointers to documentation that will allow me to set this up ? Very much appreciated! Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for pointers to mysql functions
This would be handled in your query, so get a SQL book or look into the mysql documentation... Look at the select statement, to request specific fields, as well as the Limit keyword to return a certain number of results per page. -B - Original Message - From: Stuart Felenstein [EMAIL PROTECTED] Date: Thursday, November 11, 2004 6:32 am Subject: [PHP] Looking for pointers to mysql functions I'm building a search function and I think most of the search part is solid. Now I'm trying to figure out the results part. Since my results would return about 7 fields per record, I'm thinking mysql_fetch_row over mysql results works better ? But I don't want every field from the row returned, only specific ones. Also, I want to allow for all records that meet criteria to be returned, and will set up a user variable, so they can choose how many records per page come back. Can anyone share some ideas or pointers to documentation that will allow me to set this up ? Very much appreciated! Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for pointers to mysql functions
--- [EMAIL PROTECTED] wrote: This would be handled in your query, so get a SQL book or look into the mysql documentation... Look at the select statement, to request specific fields, as well as the Limit keyword to return a certain number of results per page. -B So there is no php code I need to know to get returns on my query statement ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Looking for pointers to mysql functions
-Original Message- From: Stuart Felenstein [mailto:[EMAIL PROTECTED] Sent: 11 November 2004 11:32 To: [EMAIL PROTECTED] Subject: [PHP] Looking for pointers to mysql functions I'm building a search function and I think most of the search part is solid. Now I'm trying to figure out the results part. Since my results would return about 7 fields per record, I'm thinking mysql_fetch_row over mysql results works better ? But I don't want every field from the row returned, only specific ones. Also, I want to allow for all records that meet criteria to be returned, and will set up a user variable, so they can choose how many records per page come back. Can anyone share some ideas or pointers to documentation that will allow me to set this up ? Very much appreciated! Stuart Is this something like what you are after: ?php $sql = SELECT col1, col2, col3, col4 as colx, col5 FROM my_table WHERE col2 LIKE '%$search%' ORDER BY col3 LIMIT $from, $max_results; $result = mysql_query($sql) or die (Query failed: . mysql_error()); while($row = mysql_fetch_assoc($result)) { ? tr td?php echo $row['col2'] ?/td td?php echo $row['colx'] ?/td /tr ?php } ? For details on how to do the x rows per page with previous and next see http://www.phpfreaks.com/tutorials/43/0.php or http://www.phpfreaks.com/tutorials/73/0.php HTH Graham -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Looking for pointers to mysql functions
--- Graham Cossey [EMAIL PROTECTED] wrote: Is this something like what you are after: ?php $sql = SELECT col1, col2, col3, col4 as colx, col5 FROM my_table WHERE col2 LIKE '%$search%' ORDER BY col3 LIMIT $from, $max_results; $result = mysql_query($sql) or die (Query failed: . mysql_error()); while($row = mysql_fetch_assoc($result)) { ? tr td?php echo $row['col2'] ?/td td?php echo $row['colx'] ?/td /tr ?php } ? For details on how to do the x rows per page with previous and next see http://www.phpfreaks.com/tutorials/43/0.php or http://www.phpfreaks.com/tutorials/73/0.php HTH Graham Yes, I think this is it. I appreciate the link to the rows per page thing! Very helpful as always! Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for pointers to mysql functions
- Original Message - From: Stuart Felenstein [EMAIL PROTECTED] Date: Thursday, November 11, 2004 7:13 am Subject: Re: [PHP] Looking for pointers to mysql functions --- [EMAIL PROTECTED] wrote: This would be handled in your query, so get a SQL book or look into the mysql documentation... Look at the select statement, to request specific fields, as well as the Limit keyword to return a certain number of results per page. -B So there is no php code I need to know to get returns on my query statement ? Stuart Depends on what you want to do If you have a table with an ID, name, addr, phone for instance and you only what the Name and phone then you could handle it in your query with: select name, phone from table OR you could handle it in PHP with: $result = mysql_query(Select * from table); while($row = mysql_fetch_row($result) { echo row[1] - $row[2]br; } Perhaps a more meaningful question would lead to a more meaningful answer. -B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php