Jump to content

Recommended Posts

I am using PHPP 5 an an Apache Server 2, and a mySQL database.

 

Each row of the database contains all of the information on a single item.

 

I can display each item just fine with each item on a new row of the display table.

 

What I want to do is display a 3 column table with all the data from one item in each cell.

 

Using the php code below, I am able to display a 3 column table, however the same item displays in each cell of the same row.

 

Can anyone helb me?

 

// Setup and run query

 

  $query = "select * from items where name like '%".$searchterm."%'";

$result = $db->query($query);

$num_results = $result->num_rows;

echo "<p>Number of items found: ".$num_results."</p>";

 

// Display results

 

 

 

echo "<table border= 1>";

 

  for ($i=0; $i <$num_results; $i++)

{

 

$row = $result->fetch_assoc();

$Imge = stripslashes($row['imge']);

echo "<tr>";

for ($c=0; $c < 3; $c++)

{

echo "<td>";

 

echo "<p><strong>Number: ";

echo stripslashes($row['number']);

echo "\t \t";

echo htmlspecialchars(stripslashes($row['title']));

echo stripslashes($row['name']);

echo "</strong><br /></p>";

echo "<p align='center'><img border=\"0\" src=\"images/".$Imge."\"><br /></p>";

echo stripslashes($row['description']);

echo "<br />Price: ";

echo stripslashes($row['price']);

echo "</p>";

echo "</td>";

 

}

echo "</tr>";

}

 

 

echo "</table>";

Link to comment
https://forums.phpfreaks.com/topic/150055-multi-column-tables/
Share on other sites

Sorry, yes this is a duplicate post. computer froze and I was not sure if it had posted.

 

Unfortunately, neither suggestion helped.

 

The first, adding the WHILE loop produced invalid code.

 

The second put thr script in an endless loop.

 

any other suggestions?

Link to comment
https://forums.phpfreaks.com/topic/150055-multi-column-tables/#findComment-788436
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.