Cooper94 Posted December 24, 2008 Share Posted December 24, 2008 My code is: <? include 'db.php' ?> <?php // coonnect to database if (isset($_GET['id'])) { $sql = "SELECT date FROM pirep WHERE username='{$_GET['id']}' LIMIT 0,5"; if ($result = mysql_query($sql)) { $row = mysql_fetch_assoc($result); } else { echo "query failed ".mysql_error(); } } else { echo "No User Selected"; } ?> <br> <h1 align="center">Logged Flights</h1> <table border="0" cellpadding="5" cellspacing="0" align="center" style="font-size: 9pt; border: solid 1px"> <tr bgcolor="#b5d0e5"> <th bgcolor="#666666"><font color="#FFFFFF">Date</font></th> <th bgcolor="#006699"><font color="#FFFFFF">Departure</font></th> <th bgcolor="#666666"><font color="#FFFFFF">Arrival</font></th> <th bgcolor="#006699"><font color="#FFFFFF">Aircraft</font></th> <th bgcolor="#666666"><font color="#FFFFFF">Time</font></th> <th bgcolor="#006699"><font color="#FFFFFF">Comments</font></th> </tr> <tr> <td align="center"><?echo $row['date']; ?></td> <td align="center" height="11"><?echo $row['icao_orig']; ?></td> <td align="center" height="11"><?echo $icao_dest; ?></td> <td align="center" height="11"><?echo $aircraft; ?></td> <td align="center" height="11"><?echo $flthrs2; ?></td> <td align="center" height="11"><?echo $comments; ?></td> </tr> </table> But it only show's one not three, am I doing something wrong? Link to comment https://forums.phpfreaks.com/topic/138343-limit/ Share on other sites More sharing options...
revraz Posted December 24, 2008 Share Posted December 24, 2008 It will return up to 5, but you still need to do a while loop to display all the results. Link to comment https://forums.phpfreaks.com/topic/138343-limit/#findComment-723377 Share on other sites More sharing options...
ratcateme Posted December 24, 2008 Share Posted December 24, 2008 try <?php include 'db.php' ?> <?php // coonnect to database if (!isset($_GET['id'])) { die("No User Selected"); } $sql = "SELECT date FROM pirep WHERE username='{$_GET['id']}' LIMIT 0,5"; if (!$result = mysql_query($sql)) { die("query failed " . mysql_error()); } while (($row = mysql_fetch_assoc($result)) != false) { ?> <br> <h1 align="center">Logged Flights</h1> <table border="0" cellpadding="5" cellspacing="0" align="center" style="font-size: 9pt; border: solid 1px"> <tr bgcolor="#b5d0e5"> <th bgcolor="#666666"><font color="#FFFFFF">Date</font></th> <th bgcolor="#006699"><font color="#FFFFFF">Departure</font></th> <th bgcolor="#666666"><font color="#FFFFFF">Arrival</font></th> <th bgcolor="#006699"><font color="#FFFFFF">Aircraft</font></th> <th bgcolor="#666666"><font color="#FFFFFF">Time</font></th> <th bgcolor="#006699"><font color="#FFFFFF">Comments</font></th> </tr> <tr> <td align="center"><? echo $row['date']; ?></td> <td align="center" height="11"><? echo $row['icao_orig']; ?></td> <td align="center" height="11"><? echo $icao_dest; ?></td> <td align="center" height="11"><? echo $aircraft; ?></td> <td align="center" height="11"><? echo $flthrs2; ?></td> <td align="center" height="11"><? echo $comments; ?></td> </tr> </table> <?php } ?> you needed a loop Scott. Link to comment https://forums.phpfreaks.com/topic/138343-limit/#findComment-723378 Share on other sites More sharing options...
Cooper94 Posted December 25, 2008 Author Share Posted December 25, 2008 It works but it shows the table twice is there anyway to make it not show twice? Link to comment https://forums.phpfreaks.com/topic/138343-limit/#findComment-723421 Share on other sites More sharing options...
ratcateme Posted December 25, 2008 Share Posted December 25, 2008 just reshuffle the html <?php include 'db.php' ?> <?php // coonnect to database if (!isset($_GET['id'])) { die("No User Selected"); } $sql = "SELECT date FROM pirep WHERE username='{$_GET['id']}' LIMIT 0,5"; if (!$result = mysql_query($sql)) { die("query failed " . mysql_error()); } ?> <br> <h1 align="center">Logged Flights</h1> <table border="0" cellpadding="5" cellspacing="0" align="center" style="font-size: 9pt; border: solid 1px"> <?php while (($row = mysql_fetch_assoc($result)) != false) { ?> <tr bgcolor="#b5d0e5"> <th bgcolor="#666666"><font color="#FFFFFF">Date</font></th> <th bgcolor="#006699"><font color="#FFFFFF">Departure</font></th> <th bgcolor="#666666"><font color="#FFFFFF">Arrival</font></th> <th bgcolor="#006699"><font color="#FFFFFF">Aircraft</font></th> <th bgcolor="#666666"><font color="#FFFFFF">Time</font></th> <th bgcolor="#006699"><font color="#FFFFFF">Comments</font></th> </tr> <tr> <td align="center"><? echo $row['date']; ?></td> <td align="center" height="11"><? echo $row['icao_orig']; ?></td> <td align="center" height="11"><? echo $icao_dest; ?></td> <td align="center" height="11"><? echo $aircraft; ?></td> <td align="center" height="11"><? echo $flthrs2; ?></td> <td align="center" height="11"><? echo $comments; ?></td> </tr> <?php } ?> </table> Scott. Link to comment https://forums.phpfreaks.com/topic/138343-limit/#findComment-723463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.