Ltj_bukem Posted November 29, 2007 Share Posted November 29, 2007 Hi, I have a few queries that run fine & return the results I'm after. However I am unable to get them to display in rows/columns. I am sure that the results could be passed into a table using html. Here's my query $data_p = mysql_query("SELECT * FROM download WHERE dance LIKE '%$search%' OR name LIKE '%$search%'$max") or die(mysql_error()); This displays the results in one long list while (list($id, $name, $type,$size,$content, $dance) = mysql_fetch_array($data_p)) { echo "<a href=\"download3.php?id=$id\">$name$dance</a></br>"; } Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/79462-query-result-displayed-in-html-table/ Share on other sites More sharing options...
pocobueno1388 Posted November 29, 2007 Share Posted November 29, 2007 This question is so common there's a tutorial for it http://www.phpfreaks.com/forums/index.php/topic,95426.0.html Quote Link to comment https://forums.phpfreaks.com/topic/79462-query-result-displayed-in-html-table/#findComment-402349 Share on other sites More sharing options...
revraz Posted November 29, 2007 Share Posted November 29, 2007 Do you want a certain amount of rows before it splits to a new column? You already have the while loop, just add TD tags in there and start a TABLE before the loop and end it after it's down. If you want a certain number, then add another loop to keep track of that. Quote Link to comment https://forums.phpfreaks.com/topic/79462-query-result-displayed-in-html-table/#findComment-402350 Share on other sites More sharing options...
Ltj_bukem Posted November 29, 2007 Author Share Posted November 29, 2007 thanks, I wanted to get 2 columns, one for name and one for address. I've put the following tags in the code and the results aren't split into two colmuns. It displays like this simondavies4summitavenue, there should be a space between the two fields. while (list($id, $name, $type,$size,$content, $address) = mysql_fetch_array($data_p)) { echo "<tr><a href=\"download3.php?id=$id\">$name</a></tr>"; echo "<tr>$address</tr></br>"; Quote Link to comment https://forums.phpfreaks.com/topic/79462-query-result-displayed-in-html-table/#findComment-402397 Share on other sites More sharing options...
revraz Posted November 29, 2007 Share Posted November 29, 2007 You need to read up on how to format a table. You are using TR when you should use TD Quote Link to comment https://forums.phpfreaks.com/topic/79462-query-result-displayed-in-html-table/#findComment-402401 Share on other sites More sharing options...
Ltj_bukem Posted November 29, 2007 Author Share Posted November 29, 2007 Your right! I've kind of got it working, here's the code anyway <?php echo"<br>"; echo"<br>"; while (list($id, $name, $type,$size,$content, $dance) = mysql_fetch_array($data_p)) { echo "<tr>"; echo "<td><font size='2'font color = '#ffffff' face='Arial'><a href=\"download3.php?id=$id\">$name</a></td></font>"; echo "<td><font size='2'font color = '#ffffff' face='Arial'>$dance</td></font>"; //echo "<td><font size='2'font color = '#ffffff' face='Arial'>$id</td></font>"; echo "</tr>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/79462-query-result-displayed-in-html-table/#findComment-402422 Share on other sites More sharing options...
pocobueno1388 Posted November 29, 2007 Share Posted November 29, 2007 You need to close the <font> tags BEFORE the <td> tags. Also, where is your table tags? <?php echo"<br>"; echo"<br>"; while (list($id, $name, $type,$size,$content, $dance) = mysql_fetch_array($data_p)) { echo "<tr>"; echo "<td><font size='2'font color = '#ffffff' face='Arial'><a href=\"download3.php?id=$id\">$name</a></font></td>"; echo "<td><font size='2'font color = '#ffffff' face='Arial'>$dance</td></font>"; //echo "<td><font size='2'font color = '#ffffff' face='Arial'>$id</font></td>"; echo "</tr>"; } Your gonna have to explain what "kind of working" means...we can't really help you any further if we don't know what to help you with. Quote Link to comment https://forums.phpfreaks.com/topic/79462-query-result-displayed-in-html-table/#findComment-402425 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.