| | For example... a table have 2 columns, 100 rows for column i.e. no, name I want to get corresponding name when no=17 How to write this php coding?? |
|
|
An idea could be to Click Here: http://php.about.com/library/bl-addtut03.htm
There you find a tutorial about that, just rewrite a little on that script and it will problety work, Hope i Helped ~ Arne-Christian CODE print "<tr><td>Column 1</td><td>Column 2</td></tr>"; $query = mysql_query("SELECT * FROM table"); while($getArray = mysql_fetch_array($query)){ print "<tr><td>$getArray[number]</td><td>$getArray[name]</td></tr>";} Note that while{} is an ongoing loop, it will load any number of records wich will display a full list* of each record, showing number and the name attached to it. * To limit the number of results change the query by: CODE $query = mysql_query("SELECT * FROM table LIMIT 10 the above code would limit the number of results (rows) to 10 * To order the number of results change the query by: CODE $query = mysql_query("SELECT * FROM table ORDER BY number DESC"); the above code would order the list by number descending * To do both: CODE $query = mysql_query("SELECT * FROM table ORDER BY number DESC LIMIT 10"); any questions ill gladly answer
QUOTE(HmmZ @ Dec 27 2005, 08:46 AM) Not too hard: CODE print "<tr><td>Column 1</td><td>Column 2</td></tr>"; $query = mysql_query("SELECT * FROM table"); while($getArray = mysql_fetch_array($query)){ print "<tr><td>$getArray[number]</td><td>$getArray[name]</td></tr>";} Note that while{} is an ongoing loop, it will load any number of records wich will display a full list* of each record, showing number and the name attached to it. * To limit the number of results change the query by: CODE $query = mysql_query("SELECT * FROM table LIMIT 10 the above code would limit the number of results (rows) to 10 * To order the number of results change the query by: CODE $query = mysql_query("SELECT * FROM table ORDER BY number DESC"); the above code would order the list by number descending * To do both: CODE $query = mysql_query("SELECT * FROM table ORDER BY number DESC LIMIT 10"); any questions ill gladly answer Your method is good to deal with large data. Are there any other easy methods to show only 1 record with corresponding no. easily?
Try this code. It might help.
CODE $db = mysql_connect ("localhost", "username", "password");
mysql_select_db ("database_name"); $query=mysql_query("SELECT field1,field2 FROM table WHEN no=17"); while($row=mysql_fetch_row($query)){ echo $row[0].'<br>'.$row[1]; } QUOTE(leiaah @ Dec 27 2005, 11:39 PM) Try this code. It might help. CODE $db = mysql_connect ("localhost", "username", "password"); mysql_select_db ("database_name"); $query=mysql_query("SELECT field1,field2 FROM table WHEN no=17"); while($row=mysql_fetch_row($query)){ echo $row[0].'<br>'.$row[1]; } thx a lot
Similar Topics
Keywords : specific xx
Looking for read, specific, row, table, xx
|
|
![]() How To Read Specific Row From Table - according where no=xx |
| ADD REPLY / Got an Opinion! | Remove these ADs! | RAPID SEARCH! | Free Web Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute more info. to help others. Ask your Doubts & Queries to get answers, So that "Together We can help others!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|