Hi, is there an easier way to do this please?
I have a table of all the species discovered by each player.
I need to display the species name if it been discovered or undiscovered if not.
At present i am doing 1 query to display each but there may be hundreds of these to check.
Is there a way to do 1 query and loop through the result??
[php]
$query1 = $this->db->fetchRow(‘SELECT COUNT(*) AS count
FROM discoveries
WHERE username
=? AND species
=?’, array($username, ‘Species1’));
if ($query1->count > 0)
{ $species1 = ‘Species1’; }
else
{ $species1 = ‘Undiscovered’; }
$query2 = $this->db->fetchRow(‘SELECT COUNT(*) AS count
FROM discoveries
WHERE username
=? AND species
=?’, array($username, ‘Species2’));
if ($query2->count > 0)
{ $species2 = ‘Species2’; }
else
{ $species2 = ‘Undiscovered’; }
$query3 = $this->db->fetchRow(‘SELECT COUNT(*) AS count
FROM discoveries
WHERE username
=? AND species
=?’, array($username, ‘Species3’));
if ($query3->count > 0)
{ $species3 = ‘Species3’; }
else
{ $species3 = ‘Undiscovered’; }
[/php]