waynew Posted April 29, 2008 Share Posted April 29, 2008 Okay, when I use this page, all I get is... nothing. Not even the Title of the page will show. What do you think? <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Users</title> </head> <body><?php $user="*******"; $password="********"; $database="*********"; $conn = mysql_connect("*************" ,$user,$password); @mysql_select_db($database, $conn) or die(mysql_error); $result = mysql_query("SELECT * FROM USERS"); echo = "<TABLE>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ID'] . "</td>"; echo "<td>" . $row['NAME'] . "</td>"; echo "<td>" . $row['USERNAME'] . "</td>"; echo "<td>" . $row['EMAIL'] . "</td>"; echo "</tr>"; } echo "</TABLE>"; mysql_close($conn); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/103438-displaying-db-rows-in-a-table/ Share on other sites More sharing options...
psychowolvesbane Posted April 29, 2008 Share Posted April 29, 2008 Try: $result = mysql_query("SELECT * FROM USERS",$conn); Link to comment https://forums.phpfreaks.com/topic/103438-displaying-db-rows-in-a-table/#findComment-529678 Share on other sites More sharing options...
waynew Posted April 29, 2008 Author Share Posted April 29, 2008 No still no luck. I must note that the table contains extra columns such as password etc, but even with the "SELECT NAME, USERNAME (etc) FROM USERS," I still get jack. Link to comment https://forums.phpfreaks.com/topic/103438-displaying-db-rows-in-a-table/#findComment-529681 Share on other sites More sharing options...
waynew Posted April 29, 2008 Author Share Posted April 29, 2008 Here's the current code: $result = mysql_query("SELECT ID, EMAIL, NAME, USERNAME FROM USERS"); echo = "<TABLE>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ID'] . "</td>"; echo "<td>" . $row['NAME'] . "</td>"; echo "<td>" . $row['USERNAME'] . "</td>"; echo "<td>" . $row['EMAIL'] . "</td>"; echo "</tr>"; } echo "</TABLE>"; mysql_close($conn); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/103438-displaying-db-rows-in-a-table/#findComment-529687 Share on other sites More sharing options...
psychowolvesbane Posted April 29, 2008 Share Posted April 29, 2008 Try this as well: <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Users</title> </head> <body> <TABLE> <th>ID</th> <th>NAME</th> <th>USERNAME</th> <th>EMAIL</th> <?php $user="*******"; $password="********"; $database="*********"; $conn = mysql_connect("*************" ,$user,$password); @mysql_select_db($database, $conn) or die(mysql_error); $result = mysql_query("SELECT * FROM USERS",$conn); while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ID'] . "</td>"; echo "<td>" . $row['NAME'] . "</td>"; echo "<td>" . $row['USERNAME'] . "</td>"; echo "<td>" . $row['EMAIL'] . "</td>"; echo "</tr>"; } mysql_close($conn); ?> </TABLE> </body> </html> Link to comment https://forums.phpfreaks.com/topic/103438-displaying-db-rows-in-a-table/#findComment-529688 Share on other sites More sharing options...
psychowolvesbane Posted April 29, 2008 Share Posted April 29, 2008 PHP doesn't like echoing any of the major tags like <form> or <table> and their equivalent closing tags, it might also not like form <input>, learnt that the hard way like you about 5 months ago. Link to comment https://forums.phpfreaks.com/topic/103438-displaying-db-rows-in-a-table/#findComment-529691 Share on other sites More sharing options...
waynew Posted April 29, 2008 Author Share Posted April 29, 2008 Psycho, you're a legend. Thanks! Link to comment https://forums.phpfreaks.com/topic/103438-displaying-db-rows-in-a-table/#findComment-529696 Share on other sites More sharing options...
psychowolvesbane Posted April 29, 2008 Share Posted April 29, 2008 No problem Don't forget to use the Topic Solved button on the bottom of the page in the thread when the problem is resolved. Link to comment https://forums.phpfreaks.com/topic/103438-displaying-db-rows-in-a-table/#findComment-529737 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.