Query mysql fields and output table A: idtitle ----------------------------------- 10 test 11 Hello 12 good 13 very good PHP output: PHPcode $ test [title] array (md & gt; test ), array (md & gt; hello), array query mysql fields and output
Table:
Idtitle
---------------------------------
10 tests
11 Hello
12 Good
13 Very good
PHP output:
PHP code
$ Test ['title'] = array ('MD' => 'test'), array ('MD' => 'Hello '), array ('MD' => ''), array ('MD' => ''),);
If you want to query the mysql database, there is a question about "test, Hello, good, very good"
Id value, How should I write mysql Query statements? For example:
SQL code
SELECT * from a where A. title = "test" or A. title = "Hello" or A. title = "good" or A. title = "very good" limit
Such a query statement can only list matched data in the database. I just want him to output the ID field. what should I do?
------ Solution --------------------
SELECT * from a where A. title in ('test', '') limit
------ Solution --------------------
PHP output is relatively simple.
1. connect to the database.
2. execute select
3. mysql_fetch_array
The following cannot be entered ...... Google by myself
------ Solution --------------------
Although you are not there, I still write it out and give it to me:
$ SQL = "SELECT id, title FROM A where title in ('test', '', '',' ') limit ";
$ Link = mysql_connect ('127. 0.0.1 ', 'MySQL _ user', 'MySQL _ password ');
If (! $ Link ){
Die ('could not connect: '. mysql_error ());
}
Mysql_select_db ("mysql_database", $ link );
Mysql_query ("set names utf8 ");
$ Res = mysql_query ($ SQL );
While ($ info = mysql_fetch_assoc ($ res )){
Echo "the id number of". $ info ['title']. "is". $ info ['id']."
";
}
Over; remember to score !!