|
Posted by - Dazed on 10/10/01 11:39
"J.O. Aho" <user@example.net> wrotc:
>- Dazed wrote:
>> How do I combine the two following statements where I am selecting
>> everything from "category" where id=$id and sponsor='0' or $userid ?
>>
>> Thanks for any help!
>>
>> $result = mysql_db_query($database, "SELECT * FROM category WHERE
>> id=$id and sponsor='0'");
>>
>> $result = mysql_db_query($database, "SELECT * FROM category WHERE
>> id=$id and sponsor=$userid");
>
> From the manual: http://www.php.net/manual/en/function.mysql-db-query.php
>
>This function is deprecated, do not use this function. Use mysql_select_db()
>and mysql_query() instead.
>
>
><?PHP
>/* You should have had this before in your code */
>$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
>if (!$link) {
> die('Not connected : ' . mysql_error());
>}
>
>
>/* This select that we use yourdatabase as the current database */
>$db_selected = mysql_select_db('yourdatabase', $link);
>if (!$db_selected) {
> die ('Can\'t use foo : ' . mysql_error());
>}
>
>/* We use mysql_query() */
>$result = mysql_query("SELECT * FROM category WHERE id=$id and (sponsor='0' OR
>sponsor='$userid')");
>
>if($result) {
> while ($row = mysql_fetch_array($result)) {
> /* We just make an ugly printout of the data */
> print_r($row);
> }
>}
>?>
>
>
>
> //Aho
Thanks so much for the quick reply!!!
Navigation:
[Reply to this message]
|