dcgamers Posted April 12, 2006 Share Posted April 12, 2006 ok so i know how to display the newest data from a table, all the data from a table but i need to know how to display 5 (for instance)! How may I do So? Link to comment https://forums.phpfreaks.com/topic/7260-mysqlphp-help-how-to/ Share on other sites More sharing options...
AndyB Posted April 13, 2006 Share Posted April 13, 2006 For example ....[code]$query = "SELECT * from $db_table ORDER by $some_field DESC LIMIT 5";[/code] Link to comment https://forums.phpfreaks.com/topic/7260-mysqlphp-help-how-to/#findComment-26425 Share on other sites More sharing options...
dcgamers Posted April 13, 2006 Author Share Posted April 13, 2006 Thanks, Need help again:How to I show the number of rows of data in a table (in numbers)? Link to comment https://forums.phpfreaks.com/topic/7260-mysqlphp-help-how-to/#findComment-26434 Share on other sites More sharing options...
earl_dc10 Posted April 13, 2006 Share Posted April 13, 2006 try this :[code]$query = "SELECT * from $db_table ORDER by $some_field DESC"; // don't have a LIMIT in it$select_query = mysql_query($query, $link) or die("Couldn't select from $db_table ".mysql_error() );$num_rows = mysql_num_rows($select_query); // gets number of rows[/code] Link to comment https://forums.phpfreaks.com/topic/7260-mysqlphp-help-how-to/#findComment-26440 Share on other sites More sharing options...
dcgamers Posted April 13, 2006 Author Share Posted April 13, 2006 Thanks it worked.Hey I'm a c++ guy not a php guy :).I have one more question and it is about Mysql_query and displaying in a loop, the contents of a database table. I need to know how to be able to click on a link in the loop (per looped item that is) and make it take me to a page where there will be more data for that specific item. Sorry this may be confusing, I don't know the right term names. Link to comment https://forums.phpfreaks.com/topic/7260-mysqlphp-help-how-to/#findComment-26454 Share on other sites More sharing options...
adamjnz Posted April 13, 2006 Share Posted April 13, 2006 [!--quoteo(post=364269:date=Apr 13 2006, 02:39 PM:name=dcgamers)--][div class=\'quotetop\']QUOTE(dcgamers @ Apr 13 2006, 02:39 PM) [snapback]364269[/snapback][/div][div class=\'quotemain\'][!--quotec--]Thanks it worked.Hey I'm a c++ guy not a php guy :).I have one more question and it is about Mysql_query and displaying in a loop, the contents of a database table. I need to know how to be able to click on a link in the loop (per looped item that is) and make it take me to a page where there will be more data for that specific item. Sorry this may be confusing, I don't know the right term names.[/quote]Just use a one row table and echo the values from your query you want, but before the able put this line of code:[code]<?php do { ?>[/code]And after the table put the code:[code]<?php } while ($row_NAME-OF-QUERY = mysql_fetch_assoc($NAME-OF-QUERY )); ?>[/code]In the table put a link to another page something like this:[code]<a href="otherpage.php?ID=<?php echo $row_NAME-OF-QUERY['IDFEILD'];?>">More Info</a>[/code]On your second page make a query that is filtered by the URL Paramater ID and use the ID feildHope that all makes sense, not good at explaining Link to comment https://forums.phpfreaks.com/topic/7260-mysqlphp-help-how-to/#findComment-26468 Share on other sites More sharing options...
dcgamers Posted April 13, 2006 Author Share Posted April 13, 2006 can you explain better? Link to comment https://forums.phpfreaks.com/topic/7260-mysqlphp-help-how-to/#findComment-26649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.