How would i use the row location from getproduct() within getimgnav() but still retriving the rows from query within getimgnav().
I'm sure its a simple solution but my brains drawing a blank atm
public function getproduct($code)
{
if($result = $this->database->query("SELECT * FROM `products` WHERE code='$code'"))
{
return $result->fetch_array(MYSQLI_ASSOC);
}
return 0;
}
public function getimgnav($product, $num = 9)
{
$product = $this->database->antisql($product);
if($results = $this->database->query("SELECT * FROM `products` LIMIT $num"))
{
$results->data_seek($results->current_field - 4);
while($row = $results->fetch_array(MYSQLI_ASSOC))
{
if($row['code'] == $product)
{
echo '<li><a href="/products/' . $row['code'] .
'/" class="active"><img src="' . $row['image_thumb'] .
'" alt="' . $row['name'] . '"/></a></li>' . "\n";
}
else
{
echo '<li><a href="/products/' . $row['code'] . '/"><img src="' .
$row['image_thumb'] . '" alt="' . $row['name'] .
'"/></a></li>' . "\n";
}
}
}
}
Reformatted code to aid readability here -- NogDog