Forum Moderators: coopster
I have the following:
$sql= "select shopname from shop where exits SELECT shopname FROM shop where shoptype = '$_POST[option]'";
Its embedded within php.
keep getting error:
sportsselect shopname from shop where exits SELECT shopname FROM shop where shoptype = 'sports'
Warning: pg_exec(): Query failed: ERROR: parser: parse error at or near "SELECT" at character 39 . in /home/students/ug/ug75ixc/public_html/shops/storeSearch.php on line 46
i know what i am doing, but i dont think i got syntax right, can anyone help
EXISTS keyword spelled incorrectly: $sql= "select shopname from shop where EXISTS (SELECT shopname FROM shop where shoptype = '$_POST[option]')";
But what is it exactly that you are trying to accomplish? I'm not so sure you need an
EXISTS predicate here, nor a subquery. You may be getting a result set that you aren't expecting.
basically what i am trying to do is select the shop names from the table based on the users choice.
But i want the results to come out alphabetically
For example:
if the user wants to dipsly results of clothes shop this query would be used:
SELECT * FROM shop where shoptype = 'clothes'
in php scipt its
SELECT * FROM shop where shoptype = '$POST[option]';
so how would i do it if i wanted these results to be displayed alphabetically
NOTICEerrors. There are a number of ways to overcome this issue, but here is one correct way:
$sql = "SELECT * FROM shop where shoptype = '" . $POST['option'] . "' ORDER BY shoptype; See the PHP Array do's and don'ts [php.net] for more information regarding this practice.