|
Posted by Pedro Graca on 10/08/06 02:17
[ crossposted by me to comp.lang.php, followups set ]
Garry Jones wrote (in comp.databases.mysql):
> I am having trouble with the syntax of select. (using php and mysql
> combined) The user keys in a number and I want to look for that field (only
> one field can have that value as its created automaticaly upon dataentry)
> Based upon the number the user keys in I want to retrieve another field from
> the same record
>
> This is not working. How do I do it?
>
> $scfchknum=$_POST['scfchknum'];
> (inlogging mysql)
> $upgcollect='SELECT scfpwd1 FROM scfmforening WHERE scfmnum = $scfchknum';
> (logout mysql)
> $pwd1=mysql_query($upgcollect);
/*
$pwd1 is a `resource`. The data in this resource can be fetched with
mysql_fetch_*() or mysql_result().
http://www.php.net/mysql_result
http://www.php.net/mysql_fetch_row
http://www.php.net/mysql_fetch_array
http://www.php.net/mysql_fetch_assoc
http://www.php.net/mysql_fetch_object
*/
if (!$pwd1) {
echo 'Query failed because: ', mysql_error();
} else {
if (($num_rows = mysql_num_rows($pwd1)) == 1) {
echo mysql_result($pwd1, 0);
} else {
echo 'Number of rows returned: ', $num_rows;
}
}
> mysql_close();
--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
Navigation:
[Reply to this message]
|