I would like to ask a question about how to judge after querying the database output.

Source: Internet
Author: User
Ask a question about how to judge after querying the database output! & Lt ;? Php $ mysql_server_name = 'localhost'; $ mysql_username = 'root'; $ mysql_password = '000000'; $ mysql_database = 'you '; $ conn & nb ask a question about how to query the database output for judgment!


$mysql_server_name='localhost';
$mysql_username='root';
$mysql_password='123456';
$mysql_database='you';

$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);

mysql_select_db($mysql_database,$conn);

mysql_query("set names 'utf8'");

$sql = "SELECT * FROM `member` WHERE username LIKE 'xiha'";

$result = mysql_query($sql,$conn);

$row = mysql_fetch_array($result);

mysql_close($conn); 

if($row['groupid'] = '1'){
        $capacity = '100';
} else if($row['groupid'] = '10'){
        $capacity = '1000';
} else {
        exit();
}

echo $capacity;

?>


The database format is:

Uid username groupid
1 haha 1
2 xiha 10

If elseif:
The output $ capacity is always the first judgment value of 100.
If ($ row ['groupid'] = '1 '){
$ Capacity = '000000 ';
}


------ Solution --------------------
If ($ row ['groupid'] = '1 '){

One = is a value assignment.
Two are the comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.