Jump to content

Multi-column tables


mdburden

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.