Jump to content

Recommended Posts

i'd like to echo my search results into a table.. but say there is multiple results

 

e.g. echo <table><td><tr>$results</tr></td> </table>

 

 

say i had two results it would be

 

echo <table><td><tr>$results</tr><tr>$results</tr></td> </table>

 

how do i do this 1 column, multiple rows for multiple results?

 

Link to comment
https://forums.phpfreaks.com/topic/169005-solved-echo-search-results-into-a-table/
Share on other sites

if it's just one column i'd probably do something besides a table, like divs.

 

but you just have to start the table before the loop and end it after...

 

echo "<table>";

 

while ($row = mysql_fetch_array($result))

{

  echo "<tr><td>".$row['results']."</td></tr>";

}

 

echo "</table>";

 

 

 

edit: i'm assuming you mean results from a database, guess you never specified where you are getting them from

hi,

 

    while ($runrows = mysql_fetch_assoc($run))

    {

              //get data

        $name = $runrows['name'];

        $image = $runrows['image'];

        $hyperlink = $runrows['hyperlink'];

        $currency = $runrows ['currency'];

        $info = $runrows ['info'];

       

        echo " <b>$name</b><br>

        <img src='$image'>

        <br>

        <a href='$hyperlink'>$hyperlink</a><p>

        ";

 

this is what i'm echoing at the moment.. i trying for the image in the column 1 row  and the next row a new image. so i changed to this

 

    while ($runrows = mysql_fetch_assoc($run))

    {

              //get data

        $name = $runrows['name'];

        $image = $runrows['image'];

        $hyperlink = $runrows['hyperlink'];

        $currency = $runrows ['currency'];

        $info = $runrows ['info'];

       

      echo "<table>";

 

while ($runrows = mysql_fetch_array($run))

{

  echo "<tr><td>".$runrows['image']."</td></tr>";

}

 

echo "</table>";

 

it is working but not displaying image, any idea why?

i changed it to this

 

    while ($runrows = mysql_fetch_assoc($run))

    {

              //get data

        $name = $runrows['name'];

        $image = $runrows['image'];

        $hyperlink = $runrows['hyperlink'];

        $currency = $runrows ['currency'];

        $info = $runrows ['info'];

       

      echo "<table>

 

while ($runrows = mysql_fetch_array($run))

{

  <tr><td><img src='$image'></td></tr>;

}

 

</table>";

 

its showing the image, i have no idea if its in a table  but before the image i get this message  "while (Array = mysql_fetch_array(Resource id #2)) { ; } "

 

:'(

If you want to PM me the code I can take a look.  I find tables really irritating because they are hard for me to keep track of.  I usually CSS border the td element in the table for troubleshooting and formatting purposes.

 

You are getting the "while (Array = " because it is contained in your echo statement from the previous line.

 

try this:

//start table output here otherwise you will be writing a <table> tag for every mysql_fetch_assoc
echo '<table>';

//one row at a time
while($runrows=mysql_fetch_assoc($run))
{
$name=$runrows['name'];
$image=$runrows['image'];
$hyperlink=$runrows['hyperlink'];
$currency=$runrows['currency'];
$info=$runrows['info'];
echo '<tr>';
echo '<td><img src='.$image.'></td>';
echo '<tr />';	
}
echo '</table>';

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.