Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying Cells in Columns, then rows in PHP
    primarykey
    data
    text
    <p>I have a table that I would like to display 5 columns or 5 cells across before starting the next row. Example </p> <p>If I had 25 records they would be displayed in a table 5 columns wide by 5 rows long instead of 25 rows.</p> <p>Below is my code.</p> <pre><code>&lt;?php require_once('../../Connections/rec.php'); ?&gt; &lt;?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION &lt; 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_rec, $rec); $query_Teams = "SELECT * FROM rec_manager"; $Teams = mysql_query($query_Teams, $rec) or die(mysql_error()); $row_Teams = mysql_fetch_assoc($Teams); $totalRows_Teams = mysql_num_rows($Teams); ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;style type="text/css"&gt; body { background-color: #000; } .Manager { color: #FFF; text-align: center; text-decoration:none } a:link { color:white; text-decoration:none } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;table border="0"&gt; &lt;?php do { ?&gt; &lt;tr&gt; &lt;td&gt;&lt;img src="&lt;?php echo $row_Teams['Team']; ?&gt;" width="138" height="92" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr class="Manager"&gt; &lt;td&gt;&lt;a href="mailto:&lt;?php echo $row_Teams['Email']; ?&gt;"&gt;&lt;?php echo $row_Teams['First_Name']; ?&gt; &lt;?php echo $row_Teams['Last_Name']; ?&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } while ($row_Teams = mysql_fetch_assoc($Teams)); ?&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php mysql_free_result($Teams); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload