jaydeesmalls Posted April 28, 2008 Share Posted April 28, 2008 I hope this makes sense. I have some text, describing what going to be in this table, then I have this: <?php $query="SELECT * FROM $tbl_name WHERE user_id >'1' AND user_id <'4'"; $result=mysql_query($query); echo "<table border='0'>"; echo "<tr>"; echo "<th>Name</th><th>Email</th>"; echo "</tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>", $row['name'], "</td><td>", $row['email'], "</td>"; echo "</tr>"; } Then I want to have some more text describing what's going to be in the next table, and I want this: <?php $query="SELECT * FROM $tbl_name WHERE user_id >'3' AND user_id <'9'"; $result=mysql_query($query); echo "<table border='0'>"; echo "<tr>"; echo "<th>Name</th><th>Email</th>"; echo "</tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>", $row['name'], "</td><td>", $row['email'], "</td>"; echo "</tr>"; } But it's not working for me. It will either print out the first $query result, or not print anything at all. Is it possible to do this? Thank you Link to comment https://forums.phpfreaks.com/topic/103288-is-it-possible-to-show-a-rows-of-a-table-then-plain-text-then-some-more-rows/ Share on other sites More sharing options...
phorman Posted April 28, 2008 Share Posted April 28, 2008 I don't see anything wrong with the code, other than the lack of ending php marks "?>" in their proper places. <?php $query="SELECT * FROM $tbl_name WHERE user_id >'1' AND user_id <'4'"; $result=mysql_query($query); echo "<table border='0'>"; echo "<tr>"; echo "<th>Name</th><th>Email</th>"; echo "</tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>", $row['name'], "</td><td>", $row['email'], "</td>"; echo "</tr>"; } ?> // -- this line was added Then I want to have some more text describing what's going to be in the next table, and I want this: <?php $query="SELECT * FROM $tbl_name WHERE user_id >'3' AND user_id <'9'"; $result=mysql_query($query); echo "<table border='0'>"; echo "<tr>"; echo "<th>Name</th><th>Email</th>"; echo "</tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>", $row['name'], "</td><td>", $row['email'], "</td>"; echo "</tr>"; } ?> // this line was added I would also suggest you call the link reference you captured from mysql connect, in your mysql_query function. ex: $result=mysql_query($query,$link); Link to comment https://forums.phpfreaks.com/topic/103288-is-it-possible-to-show-a-rows-of-a-table-then-plain-text-then-some-more-rows/#findComment-529010 Share on other sites More sharing options...
twilightnights Posted April 28, 2008 Share Posted April 28, 2008 I don't see a closing tag for php, and why do you open it twice. You could put the text you want to describe w/ in an echo. Or close the php tag either way Link to comment https://forums.phpfreaks.com/topic/103288-is-it-possible-to-show-a-rows-of-a-table-then-plain-text-then-some-more-rows/#findComment-529127 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.