Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here, I cleaned up your invalid HTML, used CSS, and used a more recommended PHP coding style.</p> <p>Please note: you need to be aware that if <code>$Selected</code> contains user-inputted (or otherwise non-HTML-safe) data, you need to wrap your output in <a href="http://us2.php.net/manual/en/function.htmlspecialchars.php" rel="noreferrer"><code>htmlspecialchars</code></a> or be open to XSS vulnerabilities.</p> <p>It was a little unclear what you meant by wanting to "restrict the images to three per row" considering that it was only showing 1 per row currently. If I am to assume that you want to show 3 per row rather than 1, than you need to use the modulus operator and only open a new <code>&lt;tr&gt;</code> after every third element, and then close it at the right time. Like this:</p> <pre><code>&lt;style type="text/css"&gt; a img { border: none; } .friend-list { border: none; width: 25%; height: 25%; margin: 0 auto; } .friend-list th { text-align: center; background-color: #4b2d0e; color: #fff; font-weight: bold; } .friend-list td { background-color: #999999; } &lt;/style&gt; &lt;?php $numCols = 3; $colCount = -1; ?&gt; &lt;table class="friend-list"&gt; &lt;tr&gt; &lt;th colspan="&lt;?php echo $numCols; ?&gt;"&gt;Friend List&lt;/th&gt; &lt;/tr&gt; &lt;?php foreach($Selected as $row) { $value = $row['dPath']; $imgp = ($value) ? base_url().'images/'.$value : '../images/us.png'; if(++$colCount % $numCols == 0) { echo '&lt;tr&gt;'; } ?&gt; &lt;td&gt; &lt;strong&gt;&lt;?php echo $row['dFriendName']; ?&gt;&lt;/strong&gt;&lt;br /&gt; &lt;a class="Tab_Link" href="&lt;?php echo site_url(); ?&gt;/friends/View_FProfile/&lt;?php echo $row['dMember_Id']; ?&gt;"&gt; &lt;img src="&lt;?php echo $imgp; ?&gt;" width="90" height="80" /&gt; &lt;/a&gt; &lt;/td&gt; &lt;?php if(($colCount + 1) % $numCols == 0) { echo '&lt;/tr&gt;'; } elseif (($colCount + 1) == count($Selected)) { // if 16 elements are to fit in 3 columns, print 2 empty &lt;td&gt;s before closing &lt;tr&gt; $extraTDs = $numCols - (($colCount + 1) % $numCols); for ($i = 0; $i &lt; $extraTDs; $i++) { echo '&lt;td&gt;&amp;nbsp;&lt;/td&gt;'; } echo '&lt;/tr&gt;'; } } ?&gt; &lt;/table&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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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