get only one row in mysql 1

get only one row in mysql

$q = "select whatIwant FROM table where id = 'myId' LIMIT 1";
$r = mysql_query($q);
while($i = mysql_fetch_array($r)) {
   $j = $i['whatIwant'];
}
echo $j;

Here is what the above code is Doing:
1. It’s selecting the value of whatIwant from the table where the id is myId.
2. It’s putting the value of whatIwant into the variable $j.
3. It’s echoing the value of $j.

Similar Posts