Mysql_fetch_array ($ SQL) [& # x27; field name & # x27 ;]

Source: Internet
Author: User
Can I use a syntax like mysql_fetch_array ($ SQL) [field name? I have already determined whether this record exists in the Database. Now I just want to retrieve the record in a field and write it in this way. $ is the syntax like $ username mysql_fetch_array ($ SQL Execution statement) [username field name? The output $ username is correct, because it is a beginner contact with PHP

Can I use a syntax like mysql_fetch_array ($ SQL) [field name? I have already determined whether this record exists in the Database. Now I just want to retrieve the record in a field and write it in this way. $ username = mysql_fetch_array ($ SQL Execution Statement) ['username field name'] Can I use this syntax? The output $ username is correct, because it is a beginner contact with PHP

Can I use a syntax like mysql_fetch_array ($ SQL) ['field name?
This record already exists in the Database

Now I just want to retrieve records from a field.

Is it appropriate to write this Code directly?

$ Username = mysql_fetch_array ($ SQL Execution statement) ['username field name'] Can I use this syntax?

The output $ username is correct. Many functions are not familiar with PHP since it is a beginner.

If you have better code, please highlight it. Thank you!

The complete code is as follows:


$ Defined ID = 88;
$ SQL = mysql_query ("select User Name field from table where ID = '$ defined id'", $ conn );
If (! Mysql_num_rows ($ SQL )){
$ Username = "empty ";
}
Else
{
$ Username = mysql_fetch_array ($ SQL) ['username field'];
}



Is there anything wrong with the above Code? Thank you very much for your simple and clear code!

------ Solution ----------------------
Yes, but php5.4 and above are required.
------ Solution ----------------------
Now mysqli is used more .... See http://www.jb51.net/article/28103.htm

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.