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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.