August C. August C. - 1 year ago 56
PHP Question

From a query, place the information in horizontal manner on a table

I have the following query

$res = mysql_query ("SELECT * FROM books",$conexion);

echo $row["Name"];

I want to place it in horizontal manner in a table like this

Name1 Name2 Name3 Name4
Name5 Name6 Name7 Name8
Name9 Name10 Name11 Name12

instead of


Answer Source

This should give you an idea of what you need to look at. Basically you are looping through the results you have collected and displaying them inside a table row. Each result will be inside it's own cell within the row.

    foreach( $result as $key )
      echo "<td>$key</td>";

You will need to adjust the array supplied $array but it is the basis of what you need.