|
Posted by Rik Wasmus on 11/30/07 17:32
On Fri, 30 Nov 2007 17:07:42 +0100, <sales@freeweekends.co.uk> wrote:
> Am trying Else-If but encounter a problem (newbie question, sorry)
>
> Step 1 - Create selection of companies ordered by a priority number.
>
> $query =3D "SELECT company, priority FROM foo1 WHERE foo2 AND priority=
> IN
> ('0', '1', '2') ORDER BY priority";
>
> $result =3D mysql_query($query) or die ('Error in query: $query . ' .
> mysql_error());
> while($row =3D mysql_fetch_object($result))
> $priority =3D $row['priority'];
> $company =3D $row['company'];
> The ElseIf however does not recognise if $priority equals either 1 or=
> 2, even though it does, and it outputs only the condition for if
> ($priority =3D=3D '0')
Either use mysql_fetch_array()/mysql_fetch_assoc() and use arrays =
($row['fieldname'], or use mysql_fetch_object and use $row->fieldname.
> if ($priority =3D=3D '0')
> elseif ($priority =3D=3D '1')
> elseif ($priority =3D=3D '2')
This seems better suited to a switch statement.
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|