chrisis11 Posted November 27, 2009 Share Posted November 27, 2009 Ok, quite a simple question today' For my jalapeno peppers again <?php // Make a MySQL Connection mysql_connect("localhost", "myusername", "mypassword") or die(mysql_error()); mysql_select_db("the database") or die(mysql_error()); // Get all the data from the "example" table $result = mysql_query("SELECT * FROM database") or die(mysql_error()); echo "<table border='1' bordercolor='#006600' width='98%'>"; echo "<tr> <th>Day Number</th> <th>Stage Of Growth</th> <th>Current Height (mm)</th> <th>Hours of Light/Dark</th> <th>Humidity</th> <th>Temperature</th> <th>Description</th> <th>Photo</th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td align='center'>"; echo $row['day']; echo "</td><td align='center'>"; echo $row['stage']; echo "</td><td align='center'>"; echo $row['height']; echo "</td><td align='center'>"; echo $row['hours']; echo "</td><td align='center'>"; echo $row['humidity']; echo "</td><td align='center'>"; echo $row['temperature']; echo "</td><td align='center'>"; echo $row['description']; echo "</td><td align='center'"; echo "<a href='{$row['photo']}'><img src='thumbs/{$row['photo']}' width='200px'/></a>"; echo "</td></tr>"; } echo "</table>"; ?> Ok guys, I have googled how to do this, but half of it doesn't work, or requires me to rewrite the script in a way I don't want to (defining $grow= "etc.." and the printing..... The table is getting a bit too long for one page now, so how would I incoprporate something into the script that basically says, if there is over 10 rows, make a new page and link to it? etc.... Don't know how else to write it...? Chris Quote Link to comment https://forums.phpfreaks.com/topic/183143-help-simple-question-echoing-database-is-too-long-on-page/ Share on other sites More sharing options...
eugene2009 Posted November 27, 2009 Share Posted November 27, 2009 google "mysql pagination" Quote Link to comment https://forums.phpfreaks.com/topic/183143-help-simple-question-echoing-database-is-too-long-on-page/#findComment-966532 Share on other sites More sharing options...
chrisis11 Posted November 27, 2009 Author Share Posted November 27, 2009 Thankyou, am looking into it now, ill leave topic open incase I get stuck :| Chris Quote Link to comment https://forums.phpfreaks.com/topic/183143-help-simple-question-echoing-database-is-too-long-on-page/#findComment-966533 Share on other sites More sharing options...
eugene2009 Posted November 27, 2009 Share Posted November 27, 2009 feel free to ask me directly.. if you have any questions.. Quote Link to comment https://forums.phpfreaks.com/topic/183143-help-simple-question-echoing-database-is-too-long-on-page/#findComment-966536 Share on other sites More sharing options...
chrisis11 Posted November 27, 2009 Author Share Posted November 27, 2009 By the looks of all this, it doesnt look a greatly easy subject..... Is there any way to make this quick? Chris Quote Link to comment https://forums.phpfreaks.com/topic/183143-help-simple-question-echoing-database-is-too-long-on-page/#findComment-966537 Share on other sites More sharing options...
Alex Posted November 27, 2009 Share Posted November 27, 2009 I'd take a look at this tutorial: http://www.phpfreaks.com/tutorial/basic-pagination Quote Link to comment https://forums.phpfreaks.com/topic/183143-help-simple-question-echoing-database-is-too-long-on-page/#findComment-966538 Share on other sites More sharing options...
eugene2009 Posted November 27, 2009 Share Posted November 27, 2009 i think that tutorial posted above is as simple as it gets.. Quote Link to comment https://forums.phpfreaks.com/topic/183143-help-simple-question-echoing-database-is-too-long-on-page/#findComment-966540 Share on other sites More sharing options...
chrisis11 Posted November 27, 2009 Author Share Posted November 27, 2009 Thaaaankyou guys once again Chris Quote Link to comment https://forums.phpfreaks.com/topic/183143-help-simple-question-echoing-database-is-too-long-on-page/#findComment-966556 Share on other sites More sharing options...
eugene2009 Posted November 27, 2009 Share Posted November 27, 2009 did you figure it out? Quote Link to comment https://forums.phpfreaks.com/topic/183143-help-simple-question-echoing-database-is-too-long-on-page/#findComment-966557 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.