AoN
Internet Programmer
- Aug 1, 2012
- 114
I call myself an Internet Programmer (Webmaster), yet here I am looking for help on it. :S
Here's the short version. It's meant to be a "portfolio" (not much there because most of my work wasn't "legit"). You can see the simplied (written entirely in HTML/JavaScript) at Zrift.com - The Rift is Open. The below code can be seen at Zrift.com - The Rift is Open.
Now, it is a little more complicated than the title suggests. In addition to splitting it by three rows, I'm trying to dictate how it displays by calculating if it's the last one of not. Basically (if you have a slow Internet connection you already saw this from the live version), if I don't have a complete row it would put in a blank one with an image saying "No Template Available". I want that to go away. Instead, if there's only enough for 2 in the last row, for it to center those two, same with one.
If you take a look at the test page, you'll see what is happening with my current code. Any ideas on what I did wrong?
Here's the short version. It's meant to be a "portfolio" (not much there because most of my work wasn't "legit"). You can see the simplied (written entirely in HTML/JavaScript) at Zrift.com - The Rift is Open. The below code can be seen at Zrift.com - The Rift is Open.
Now, it is a little more complicated than the title suggests. In addition to splitting it by three rows, I'm trying to dictate how it displays by calculating if it's the last one of not. Basically (if you have a slow Internet connection you already saw this from the live version), if I don't have a complete row it would put in a blank one with an image saying "No Template Available". I want that to go away. Instead, if there's only enough for 2 in the last row, for it to center those two, same with one.
If you take a look at the test page, you'll see what is happening with my current code. Any ideas on what I did wrong?
Code:
$query = mysql_query('SELECT `id`, `name`, `icon` FROM `portfolio` ORDER BY `id`');
$num = mysql_num_rows($query);
$i = 0;
$count = 0;
while($i < $num)
{
$id = mysql_result($query,$i,'id');
$name = mysql_result($query,$i,'name');
$icon = mysql_result($query,$i,'icon');
$code = '
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td background="templates/Lost_Love/images/content/box/port_top_bg.jpg" width="120" height="9"></td>
</tr>
<tr>
<td align="center" background="templates/Lost_Love/images/content/box/port_middle_bg.jpg" width="120">
<table border="0" cellpadding="0" cellspacing="0" width="100">
<tr>
<td background="templates/Lost_Love/images/content/box/port_screen_bg.jpg" style="border:0px;" width="100" height="100"><a href="javascript:unhide(\'port_viewer' . $id . '\');" title="' . $name . '"><img src="port/' . $icon . '"></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td background="templates/Lost_Love/images/content/box/port_bottom_bg.jpg" width="120" height="9"></td>
</tr>
</table>
</td>';
if($count == 0)
{
if($i = $num - 1)
{
echo '
<tr>' . $code . '
</tr>';
}
else
{
echo '
<tr>' . $code;
$count = 1;
}
}
else if($count == 1)
{
if($i = $num - 1)
{
echo '
<td width="15"></td>' . $code . '
</tr>';
$count = 0;
}
else
{
echo '
<td width="15"></td>' . $code . '
<td width="15"></td>';
$count = 2;
}
}
else
{
echo $code . '
</tr>';
$count = 0;
}
$i++;
}