Re: How to Select
| From: | Marek Kilimajer | Date: | Fri, 15 Aug 2003 10:55:10 +0000 |
| Subject: | Re: How to Select | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-159664@lists.php.net to get a copy of this message | ||
$news = mysql_query("select StudentId FROM $table");
if($mydata=mysql_fetch_object($news))
{
//got it
} else {
// no such StudentId
}
John Taylor-Johnston wrote:
Ok, this is a basic MySQL question, but I don't know how to code it in PHP. I want to check in StudentId. If it exists, ...
Anyone good humoured who would help me fill in the blank. Like I should know this, but haven't even thought of coding SQL in a while :)
$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);
$news = mysql_query("select StudentId $table");
while ($mydata = mysql_fetch_object($news))
{
}
if exists
{do this}else{do that}