Achilles
Achilles

Reputation: 504

PHP/MYSQL select Limit by two Columns

I wrote a little script for read data from mysql . but i've a little problem ,

this is my code :

    <?php
$con=mysql_connect('localhost','user','pass');
mysql_query("set names utf8");
mysql_query("set charset utf8");
mysql_set_charset('utf8');  
mysql_select_db('dbname',$con);
$query="SELECT * FROM profiles where user_id=11";
$select=mysql_query($query);
while($row=mysql_fetch_array($select)){
echo $row['value'].'  '.'';
}
mysql_close($con);

?>

for now , the script read value of column user_id = 11 , I've another column " key " , how can i read data from this row if , user_id = 11 and key = Age ?

can you help me about this issue ?

Thank you

Upvotes: 0

Views: 103

Answers (2)

lulco
lulco

Reputation: 524

use

`key`='Age'

KEY is reserved word in mysql

Upvotes: 2

Change the echo $row['value']. Instead of the word value, use the column name.

Upvotes: 0

Related Questions