Re: Else If



On Fri, 30 Nov 2007 17:07:42 +0100, <sales@xxxxxxxxxxxxxxxxxx> wrote:

Am trying Else-If but encounter a problem (newbie question, sorry)

Step 1 - Create selection of companies ordered by a priority number.

$query = "SELECT company, priority FROM foo1 WHERE foo2 AND priority
IN
('0', '1', '2') ORDER BY priority";

$result = mysql_query($query) or die ('Error in query: $query . ' .
mysql_error());
while($row = mysql_fetch_object($result))

$priority = $row['priority'];
$company = $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 == '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 == '0')
elseif ($priority == '1')
elseif ($priority == '2')

This seems better suited to a switch statement.
--
Rik Wasmus
.



Relevant Pages

  • Else If
    ... Step 1 - Create selection of companies ordered by a priority number. ... echo $priority; ... elseif ...
    (comp.lang.php)
  • Re: macros do not work the same on different computers
    ... one of the top-level selections, no matter which selection they choose ... .Add "Addition, Deletion, or Priority" ...
    (microsoft.public.word.vba.general)
  • Re: WHEN-ELSE vs CASE statement
    ... as that will generate a mux instead of a long priority selection chain. ... requires overlapping cases. ... Synthesis is not free to create priority logic based on a keyword alone. ... The if statement with zero or one else clauses. ...
    (comp.lang.vhdl)
  • Re: 1.9 patch computer question
    ... This is the affinity selection in task manager. ... Some games don't like running on multiple CPU's. ... > The games priority is just that, ... DVD burn. ...
    (alt.games.warcraft)
  • Re: OT: Was Barbara Bush ever a blonde?
    ... Nice selection of "Most Important Priority" Making sure the stock market rises? ... Fighting for 2nd Amendment rights? ...
    (alt.marketing.online.ebay)