bchandel Posted August 23, 2009 Share Posted August 23, 2009 I have the following script out put from which can be seen at http://chandel.com/try.php How can I modify this script to display: 1. Results: Number of records found 2. one record per page and then to put Next and Previous text to navigate Back and Forth for navigation <html> <body> <?php $db_connect = mysql_connect("xxxx.com", "xxxx_user", "password"); mysql_select_db("xxxx_database"); $query="SELECT * FROM Directory"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); print "<h1><center>My Directory</center></h1><br>"; $i=0; while ($i < $num) { $Name=mysql_result($result,$i,"Name"); $LastName=mysql_result($result,$i,"LastName"); $FirstName=mysql_result($result,$i,"FirstName"); $Phone=mysql_result($result,$i,"Phone"); $Mobile=mysql_result($result,$i,"Mobile"); $Email=mysql_result($result,$i,"Email"); $Web=mysql_result($result,$i,"Web"); $State=mysql_result($result,$i,"State"); $Country=mysql_result($result,$i,"Country"); echo "<b>$Name</b><br> FirstName: $FirstName<br> Home Phone: $Phone<br> Mobile: $Mobile<br> Email: $Email<br> Web Site: $Web<br> State: $State<br> Country:$Country<br><hr><br>"; $i++; } ?> </body> </head> Quote Link to comment Share on other sites More sharing options...
phpretard Posted August 23, 2009 Share Posted August 23, 2009 mysql_num_rows($result); Quote Link to comment Share on other sites More sharing options...
bchandel Posted August 23, 2009 Author Share Posted August 23, 2009 Thank you for your quick help. What $num=mysql_numrows($result); is doing in this script. Can i change as below to make it work? Look where I added: echo "Search Results: mysql_num_rows($result); found <html> <body> <?php $db_connect = mysql_connect("xxxx.com", "xxxx_user", "password"); mysql_select_db("xxxx_database"); $query="SELECT * FROM Directory"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); print "<h1><center>My Directory</center></h1><br>"; $i=0; while ($i < $num) { echo "Search Results: mysql_num_rows($result); found $Name=mysql_result($result,$i,"Name"); $LastName=mysql_result($result,$i,"LastName"); $FirstName=mysql_result($result,$i,"FirstName"); $Phone=mysql_result($result,$i,"Phone"); $Mobile=mysql_result($result,$i,"Mobile"); $Email=mysql_result($result,$i,"Email"); $Web=mysql_result($result,$i,"Web"); $State=mysql_result($result,$i,"State"); $Country=mysql_result($result,$i,"Country"); echo "<b>$Name</b><br> FirstName: $FirstName<br> Home Phone: $Phone<br> Mobile: $Mobile<br> Email: $Email<br> Web Site: $Web<br> State: $State<br> Country:$Country<br><hr><br>"; $i++; } ?> </body> </head> Quote Link to comment Share on other sites More sharing options...
phpretard Posted August 23, 2009 Share Posted August 23, 2009 if you are going to do that... <html> <body> <?php $db_connect = mysql_connect("xxxx.com", "xxxx_user", "password"); mysql_select_db("xxxx_database"); $query="SELECT * FROM Directory"; $result=mysql_query($query); $num=mysql_num_rows($result); // CHANGE IT HERE mysql_close(); print "<h1><center>My Directory</center></h1><br>"; $i=0; while ($i < $num) { echo "Search Results: $num found"; // CHANGE HERE $Name=mysql_result($result,$i,"Name"); $LastName=mysql_result($result,$i,"LastName"); $FirstName=mysql_result($result,$i,"FirstName"); $Phone=mysql_result($result,$i,"Phone"); $Mobile=mysql_result($result,$i,"Mobile"); $Email=mysql_result($result,$i,"Email"); $Web=mysql_result($result,$i,"Web"); $State=mysql_result($result,$i,"State"); $Country=mysql_result($result,$i,"Country"); echo "<b>$Name</b><br> FirstName: $FirstName<br> Home Phone: $Phone<br> Mobile: $Mobile<br> Email: $Email<br> Web Site: $Web<br> State: $State<br> Country:$Country<br><hr><br>"; $i++; } ?> </body> </head> Quote Link to comment Share on other sites More sharing options...
bchandel Posted August 23, 2009 Author Share Posted August 23, 2009 Thank you very much for your help. With some modifications the script is working good. You can see display from the script at http://chandel.com/try/try3.php What do I need to do if I only want to show one result on one page and want to put next and previous pagination on the bottom for easy navigation of the results. Thank you much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.