Jump to content

Retrieving MySQL Entries Into A Table


CrownVictoriaCop

Recommended Posts

Hey Guys,

 

I'm currently coding a script for a driving school. I programmed the code below, which goes on their homepage. They have two different locations, so I created the script below, which displays the class schedule for the two locations in a single table. Unfortunately, it is not displaying all of my test values. I have three test entries for when location is set to "27th" and four test entries for when location is set to "greenfieldhs", but it's only displaying three entries per variable. Can someone please take a look at this and see what's going on?

 

Thanks!

 

Anthony

 <table width="100%" border="0" align="center">
    <tr>
      <td colspan="2" class="tablehead" width="50%" align="center">Milwaukee (27th Street)</td>
      <td colspan="2" class="tablehead" width="50%" align="center">Greenfield High School</td>
    </tr>
    <?php
include 'db.php';
$query="SELECT * FROM classes WHERE location='27th'";
$query2="SELECT * FROM classes WHERE location='greenfieldhs'";
$result=mysql_query($query);
$result2=mysql_query($query2);
$num=mysql_numrows($result);
$num2=mysql_numrows($result2);

mysql_close();
?>
    <?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"date");
$f2=mysql_result($result,$i,"time");
$f3=mysql_result($result2,$i,"date");
$f4=mysql_result($result2,$i,"time");
?>
    <tr>
      <td width="30%" class="tablecontent"><?php echo $f1; ?></td>
      <td width="20%" class="tablecontent"><?php echo $f2; ?></td>
      <td width="30%" class="tablecontent"><?php echo $f3; ?></td>
      <td width="20%" class="tablecontent"><?php echo $f4; ?></td>
    </tr>
<?php
$i++;
}
?>
  </table>

Link to comment
https://forums.phpfreaks.com/topic/192836-retrieving-mysql-entries-into-a-table/
Share on other sites

$num=mysql_numrows($result);
$num2=mysql_numrows($result2);

 

$num=mysql_num_rows($result);
$num2=mysql_num_rows($result2);

What am I supposed to do with these?

 

Edit: I changed the code to that, but I am still having the same problem.

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.