Please help!
I have a MySQL table with a field name 'id'. Using php5, I have made a few calls to the db and retrieved data but I am now having an issue trying to retrieve data using a variable...
The sql is very basic and looks a bit like
select hours from days where id="1"; -> this works no problem. Thing is I need the ID portion to be variable, ie: where id="$id".
I suppose my question is how do you insert a variable field into MySQL using PHP. The variable is posted by a previos form using the POST method. I have included the code below.
Please note, all else works fine, it is only when I exchange an exact id record with the wrong variable method that is ceases to do its funtion???
$id = $_POST['id'];
$sql = "select hourrate from personals where id='6'"; <---- This needs to be variable
$result = mysql_query($sql);
if (mysql_num_rows($result) == 1) {
echo '<p><b>Update Status:</b>You are up to date.</p>';
} else {
echo '<p><b>Update Status:</b>You Need to update</p> ' .
mysql_error() . '</p>';
exit("you need to update your personal area");
}
Any help would be greatly appreciated. Have been self-learning from php for dummies.
http://www.phpbuilder.com/board/newthread.php?do=newthread&f=3#
Confused