简体   繁体   中英

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

use

`key`='Age'

KEY is reserved word in mysql

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM