Reply to Re: mysql help please

Your name:

Reply:


Posted by J.O. Aho on 10/10/80 11:39

- 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация