Re: displaying a varying number of images.. in tables?!



I noticed that Message-ID:
<1122637460.994585.275610@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> from
guitarromantic@xxxxxxxxx contained the following:

>thanks for the code, but all it does it display a table of images one
>by one in rows.. not what I need. I know theoretically what I need to
>do (count the number of rows returned, and every three rows or so, echo
>a "</td><td>") but I don't know how to actually code it.

Probably not the most elegant way but...

$result=mysql_query($sql);

$row[0]="";
$columns=3;
$i=0;
$j=0;
print "<table>\n";
while($myrow=mysql_fetch_array($result)){

if($i==0 || $i%$columns!==0){
$row[$j].=" <td>".$myrow['Make']."</td>\n";
$i++;
}
else{
$j++;
$row[$j]="";
$row[$j].=" <td>".$myrow['Make']."$j</td>\n";
$i++;
}
}
while($i%$columns!==0){
$row[$j].=" <td>&nbsp;</td>\n";
$i++;
}
foreach($row as $value){
print " <tr>\n$value </tr>\n";
}
print"</table>";

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
.



Relevant Pages

  • Dynamic Table
    ... I don't want anyone to write this for me.I just need a nudge. ... I have a Db with links to images that I want to display in a table 5 columns ... Prev by Date: ...
    (alt.php)
  • Business Scorecard Manager / Reporting Services
    ... Does anyone know if/how to correctly get images to display in a ... scorecard exported to Reporting Services? ... Prev by Date: ...
    (microsoft.public.sqlserver.olap)
  • Re: Images in a combobox
    ... the code snippets were very helpful. ... now I can display the images in combobox correctly. ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: displaying a varying number of images.. in tables?!
    ... but all it does it display a table of images one ... Prev by Date: ...
    (comp.lang.php)
  • RE: problems viewing text and images
    ... particulat website that you are having problems with, ... Is it text or images that you expect to see? ... Prev by Date: ...
    (microsoft.public.windows.inetexplorer.ie6.browser)