Jump to content

Query result displayed in HTML table


Ltj_bukem

Recommended Posts

 

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?

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>";


Link to comment
Share on other sites

 

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>";


} 

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.