FW: Problem with if/elseif
| From: | NBC, KNBC) | Date: | Mon, 11 Sep 2000 21:17:22 +0000 |
| Subject: | FW: Problem with if/elseif | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-16235@lists.php.net to get a copy of this message | ||
I think I'm misunderstanding how if/elseif works with PHP3. In the example
below only the if statement is executed, the elseif and else statements are
never reached.
<?php $pg = pg_pconnect("dbname=collection host=myhost.domain.net
user=postgres");
echo "$search ";
if ($search = "Artist search") {
echo "$search ";
$result=pg_exec($pg, "select * from titles where artist ~~
'%$art%' order by artist;");
} else if ($search = "Title search") {
echo "$search ";
$result=pg_exec($pg, "select * from titles where title ~~
'%$titl%' order by title;");
} else {
echo "Push a button";
};
?>
=============================================================
When $search="Artist search" and $art="Adult" I get the proper results:
Artist search Artist search
Key Artist Title For Sale?
1 Adult Net, The Incense and Peppermints Y
4 Adult Net, The Edie Y
=============================================================
When $search="Title search" and $titl="Incense" I get all the records in my
database and the second echo "$search" reverts back to "Artist search":
Title search Artist search
Key Artist Title For Sale?
1 Adult Net, The Incense and Peppermints Y
4 Adult Net, The Edie Y
5 Alternative TV Welcome to the End of Fun Y
6 Batfish Boys, The Swamp Liquor Y
3 Creation Rebel-New Age Steppers Threat to Creation Y
7 Ministry KEOANHXO
2 New Age Steppers Action Battlefield Y
===============================================================
Am I doing something glaringly wrong? How do I get the elseif statement to
execute given my $search variable?
Thanks, Greg
Because e-mail can be altered electronically,
the integrity of this communication cannot be guaranteed.