Jump to content

Help - Simple question, echoing database, is too long on page


chrisis11

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.