Posted by Alec on 10/18/07 14:44
What am I doing wrong with this elseif condition?
$query = "SELECT company, priority FROM companyid_uks49179 WHERE
town='Bury St. Edmunds' AND category='sleep' AND priority IN
('1', '2', '3') ORDER BY priority";
This returns a result set of a number of companies with different
priority numbers from 1 to 3. see webpage http://www.freeweekends.co.uk/test3.php
I now want to create a table result for each one, with an 'elseif'
statement creating a different effect for each of the three different
priorities.
$result = mysql_query($query) or die ('Error in query: $query. ' .
mysql_error());
echo '<table border=1 cellpadding=10>';
while($row = mysql_fetch_object($result))
{
$priority = $row['priority'];
if ($priority == '1')
{
echo '<tr>';
echo "<td>$row->company</td>";
echo '<tr>';
echo "<td>test1</td>";
echo '<tr>';
}
elseif ($priority == '2')
{
echo '<tr>';
echo "<td>$row->company</td>";
echo '<tr>';
echo "<td>test2</td>";
echo '<tr>';
}
else
{
echo '<tr>';
echo "<td>$row->company</td>";
echo '<tr>';
echo "<td>test3</td>";
echo '<tr>';
}
}
echo '</table>';
This returns all the results as if they were not priority 1 or 2. See
http://www.freeweekends.co.uk/test2.php
Beginners question I know, but what am I doing wrong???
Many thanks
Alec
[Back to original message]
|