jamesxg1 Posted February 7, 2009 Share Posted February 7, 2009 here's the code: $query2 = mysql_query("SELECT * from users where username = '$username' order by firstname"); while ($row = mysql_fetch_assoc($query2)) { $firstname = $row['firstname']; $lastname = $row['lastname']; } ?> <P ALIGN=CENTER><h3>Friend Requests:</h3></P> <center> <table border="1" width="400" cellpadding="5" bgcolor="#ffffff" bordercolor="#808080" style="border-collapse: collapse;" id=""> <tr> <td align="center" width="" bgcolor="#c0c0c0"><?php print $firstname ?> <?php print $lastname ?></td> <td align="center" width="" bgcolor="#c0c0c0"><a href='../friends/Accept.php?username=<?php print $username ?>'>Accept</a> | <a href='../friends/Decline.php?username=<?php print $username ?>'>Decline</a></td> </tr> that isnt the whole code but thats the part i need working, i need it to list everything from the query and not just one at a time but i wont any ideas anyone ? Link to comment https://forums.phpfreaks.com/topic/144265-php-mysql-is-only-listing-one-row-at-a-time-please-help/ Share on other sites More sharing options...
ratcateme Posted February 7, 2009 Share Posted February 7, 2009 you need to include the html in your while loop like <?php $query2 = mysql_query("SELECT * from users where username = '$username' order by firstname"); while ($row = mysql_fetch_assoc($query2)) { $firstname = $row['firstname']; $lastname = $row['lastname']; //} ?> <P ALIGN=CENTER><h3>Friend Requests:</h3></P> <center> <table border="1" width="400" cellpadding="5" bgcolor="#ffffff" bordercolor="#808080" style="border-collapse: collapse;" id=""> <tr> <td align="center" width="" bgcolor="#c0c0c0"><?php print $firstname ?> <?php print $lastname ?></td> <td align="center" width="" bgcolor="#c0c0c0"><a href='../friends/Accept.php?username=<?php print $username ?>'>Accept</a> | <a href='../friends/Decline.php?username=<?php print $username ?>'>Decline</a></td> </tr> <?php } ?> Scott. Link to comment https://forums.phpfreaks.com/topic/144265-php-mysql-is-only-listing-one-row-at-a-time-please-help/#findComment-757082 Share on other sites More sharing options...
jamesxg1 Posted February 7, 2009 Author Share Posted February 7, 2009 you need to include the html in your while loop like <?php $query2 = mysql_query("SELECT * from users where username = '$username' order by firstname"); while ($row = mysql_fetch_assoc($query2)) { $firstname = $row['firstname']; $lastname = $row['lastname']; //} ?> <P ALIGN=CENTER><h3>Friend Requests:</h3></P> <center> <table border="1" width="400" cellpadding="5" bgcolor="#ffffff" bordercolor="#808080" style="border-collapse: collapse;" id=""> <tr> <td align="center" width="" bgcolor="#c0c0c0"><?php print $firstname ?> <?php print $lastname ?></td> <td align="center" width="" bgcolor="#c0c0c0"><a href='../friends/Accept.php?username=<?php print $username ?>'>Accept</a> | <a href='../friends/Decline.php?username=<?php print $username ?>'>Decline</a></td> </tr> <?php } ?> Scott. Hiya Scott, Do you mean i have to put this code into a external php and include it in the page i need it to work ?, Or is the code that you posted above the code i should use ?, Thanks mate. Link to comment https://forums.phpfreaks.com/topic/144265-php-mysql-is-only-listing-one-row-at-a-time-please-help/#findComment-757084 Share on other sites More sharing options...
ratcateme Posted February 8, 2009 Share Posted February 8, 2009 replace the code you posted with the code i posted you may need to remove the opening <?php tag Scott. Link to comment https://forums.phpfreaks.com/topic/144265-php-mysql-is-only-listing-one-row-at-a-time-please-help/#findComment-757086 Share on other sites More sharing options...
jamesxg1 Posted February 8, 2009 Author Share Posted February 8, 2009 replace the code you posted with the code i posted you may need to remove the opening <?php tag Scott. iv got a error :S, Parse error: syntax error, unexpected $end in Pending.php on line 37 <?php session_start(); require("../db/db.php"); //include database file require("../db/config.php"); //include configuration file require("../db/util.php"); require("../db/settings.php"); isloggedin(); accessneeded("C"); $User_to = $_SESSION['username']; $Status = "Pending"; $query = mysql_query("SELECT * from friend where friend.User_to = '$User_to' and friend.Status = '$Status'"); while ($row = mysql_fetch_assoc($query)) { $username = $row['User_fr']; } $query2 = mysql_query("SELECT * from users where username = '$username' order by firstname"); while ($row = mysql_fetch_assoc($query2)) { $firstname = $row['firstname']; $lastname = $row['lastname']; //} ?> <P ALIGN=CENTER><h3>Friend Requests:</h3></P> <center> <table border="1" width="400" cellpadding="5" bgcolor="#ffffff" bordercolor="#808080" style="border-collapse: collapse;" id=""> <tr> <td align="center" width="" bgcolor="#c0c0c0"><?php print $firstname ?> <?php print $lastname ?></td> <td align="center" width="" bgcolor="#c0c0c0"><a href='../friends/Accept.php?username=<?php print $username ?>'>Accept</a> | <a href='../friends/Decline.php?username=<?php print $username ?>'>Decline</a></td> </tr> thats the whole code so u know what the error is , Thanks Scott. Link to comment https://forums.phpfreaks.com/topic/144265-php-mysql-is-only-listing-one-row-at-a-time-please-help/#findComment-757087 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.