
Originally Posted by
Twey
PHP Code:
for($i = @$_GET['start'] or 0; $row = mysql_fetch_array($rs) && $i < @$_GET['num'] or 16; ++$i) {
if($i % $rowwidth === 0) {
if($i !== @$_GET['start'] or 0) {
Rather than these ors, which will need to be re-evaluated on subsequent iterations, why not just use separate variables?
PHP Code:
$start = isset($_GET['start']) ? $_GET['start'] : 0;
$count = isset($_GET['num']) ? $_GET['num'] : 16;
$i = $start;
while (($row = mysql_fetch_array($rs)) && ($i < $count)) {
if (($i % $rowwidth) == 0) {
if ($i != $start) {
/* ... */
}
/* ... */
}
++i;
}

Originally Posted by
e1seix
that certainly explains it, but i can't seem to alter it to fit in with the following code:
It would seem that you've missed the opening <?php delimiter. However, I would also make some further changes. The most important I will address specifically:
PHP Code:
$ID = $_GET['ID'];
$result = mysql_query("SELECT * FROM fragrances WHERE ID=$ID ORDER BY PRO")
or die(mysql_error());
Never, ever include externally obtained data in a database query without validating and sanitising it - the latter may not always be necessary. This opens oneself to SQL injection attacks. Typically, database error messages shouldn't be displayed either for the same reason; it also looks very unprofessional.
If $ID is meant to be a number, either coerce it to one or use pattern matching. Either way, errors need to be handled gracefully.
PHP Code:
<td>
<?php
// The ID parameter should be tested for existence using the isset function, with
// either a default value or an error-handling mechanism in place if missing.
//
// Assuming this is just an integer, sanitation is not necessary as a number will
// never be harmful (though it might be an invalid or unexpected value).
$ID = (int) $_GET['ID'];
$result = mysql_query("SELECT * FROM fragrances WHERE ID=$ID ORDER BY PRO");
if (!$result) {
// Redirect to an error page that does something nice, such as apologise for
// the problem - don't get technical.
// One could even take the opportunity to send an e-mail to notify someone
// of a problem, though obviously this would need to be logged to prevent it
// from being sent many times.
}
?>
<table border="0" cellpadding="5" cellspacing="0" width="500">
<?php
while (($row = mysql_fetch_array($result))) {
?>
<tr>
<td align="center" bgcolor="#ffffff" width="125">
<p class="brand_div"><?php echo $row['ima_link']; ?></p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#ffffff" width="125">
<p class="brand_head"><?php echo $row['PRO']; ?></p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#ffffff" width="125">
<p class="brand_cli"><?php echo $row['cli_link']; ?></p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#ffffff" width="500">
<hr color="#cccccc" width="125">
</td>
</tr>
<?php
}
?>
</table>
</td>
If your data is really tabular, use CSS instead of presentational attributes. Using tbody elements may be useful in grouping each block, perhaps making the hr element obsolete. If the data isn't tabular, drop the tables: table-based layouts are an abomination.
Hope that sets you on the right track.
Bookmarks