Forum Moderators: coopster
<?php
// Make a connection
$con = mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("beekeeping") or die(mysql_error());
// Get values from form
$hive_num=$_POST['hive_num'];
$result = mysql_query("SELECT * FROM inspections WHERE hive_num=$hive_num");
$num_rows($mysql_num_rows($result);
if($num_rows>1) {
echo "<table border='1'>";
echo "<tr> <th>Brood Frames</th> <th>Queen Seen</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>";
echo $row['brood_frames'];
echo "</td><td>";
echo $row['queen_seen'];
echo "</td></tr>";
}
echo "</table>";
}
elseif($num_rows)==0) {
echo "There were not records to be found.";
}
mysql_close($con);
?>
I really, really hope this database is about beekeeping.It is, I'm a beekeeper but I also love messing around building website, etc. so I thought I'd try and bring the two together somehow by storing all my records online.
else($num_rows)=0) {
echo "There were not records to be found.";
}
// Get values from form
$hive_num=$_POST['hive_num'];
$result = mysql_query("SELECT * FROM inspections WHERE hive_num=$hive_num");
If there is only one row then I'd really like it just to display one row.
else($num_rows)=0)