Do a PHP Query database page, you can now enter the version number and select Line Query, select the status can not be used, the page is as follows,
At present, the problem is that the first time to open the page is to automatically display all the data, and prompted two errors, how to modify, that is, open the page is empty, only click on the query to show, the second question is how to make the "select State" to take effect, choose to complete the execution of SQL1, choose not complete execution SQL2, The media version number and line are required options,
The one who helped change it.
Select the state of the code I wrote this, but can not execute, prompt syntax error
If%{$_request[' Zhuangtai ']}%= "done" then
$q = "SELECT *" from the "where Banben like '%{$_request[' Banben ']}% ' and linename like '%{$_request[' Xianlu ']}% ' and Z Huangtai= ' fin ' ORDER by busname ASC;
ElseIf%{$_request[' Zhuangtai ']}%= "not done" then
$q = "SELECT *" from the "where Banben like '%{$_request[' Banben ']}% ' and linename like '%{$_request[' Xianlu ']}% ' and Z huangtai= ' new ' ORDER by busname ASC;
Full code:
<title>Data query</title>
$link =mysql_connect ("localhost", "root", "12345678");
if (! $link) echo "Not connected successfully!";
else echo "connected successfully!";
mysql_select_db ("Busap", $link); Select Database
Control query criteria
If%{$_request[' Zhuangtai ']}%= "done" then
$q = "SELECT *" from the "where Banben like '%{$_request[' Banben ']}% ' and linename like '%{$_request[' Xianlu ']}% ' and Z Huangtai= ' fin ' ORDER by busname ASC;
ElseIf%{$_request[' Zhuangtai ']}%= "not done" then
$q = "SELECT *" from the "where Banben like '%{$_request[' Banben ']}% ' and linename like '%{$_request[' Xianlu ']}% ' and zhuangtai= ' new ' ORDER by busname ASC;
mysql_query ("SET NAMES GB2312"); Prevent garbled characters
$rs = mysql_query ($q); Get Data Set
$ASSOC = mysql_num_rows ($rs); The number of rows affected, originally used MYSQL_FETCH_ASSOC
echo "$ASSOC";
$row =mysql_fetch_array ($RS); Just add back to this line.
if (! $rs) {die ("Valid result!");}
?>
Line |
Center number |
Line |
Vehicle self-numbering |
Transmission mode |
Media version |
Date |
Time |
State |
do {?>
|
|
|
|
|
|
|
|
|
Reply to discussion (solution)
$q = "SELECT * from the" where Xianlu = ". $_get[' SELECT ', the multi-condition itself plus go on it can
Syntax error with. $_get Hints
Now the new progress is "Select status" available, but the first time to open the page display all content, and prompt 3 error, how to modify the open page does not query, only click Query and then query
The complete code is as follows:
Data query
$link =mysql_connect ("localhost", "root", "12345678");
if (! $link) echo "Not connected successfully!";
else echo "connected successfully!";
mysql_select_db ("Busap", $link); Select Database
Control query criteria
$q = "SELECT *" from the "where Banben like '%{$_request[' Banben ']}% ' and linename like '%{$_request[' Xianlu ']}% ' and Z Huangtai like '%{$_request[' Zhuangtai ']}% ' ORDER by busname ASC ';
mysql_query ("SET NAMES GB2312"); Prevent garbled characters
$rs = mysql_query ($q); Get Data Set
$ASSOC = mysql_num_rows ($rs); The number of rows affected, originally used MYSQL_FETCH_ASSOC
echo "$ASSOC";
$row =mysql_fetch_array ($RS); Just add back to this line.
if (! $rs) {die ("Valid result!");}
?>
Line |
Center number |
Line |
Vehicle self-numbering |
Transmission mode |
Media version |
Date |
Time |
State |
do {?>
|
|
|
|
|
|
|
|
|
Data query
if ($_request[' submit '))
{
$link =mysql_connect ("localhost", "root", "12345678");
if (! $link) echo "Not connected successfully!";
else echo "connected successfully!";
mysql_select_db ("Busap", $link); Select Database
Control query criteria
$q = "SELECT *" from the "where Banben like '%{$_request[' Banben ']}% ' and linename like '%{$_request[' Xianlu ']}% ' and Z Huangtai like '%{$_request[' Zhuangtai ']}% ' ORDER by busname ASC ';
mysql_query ("SET NAMES GB2312"); Prevent garbled characters
$rs = mysql_query ($q); Get Data Set
$ASSOC = mysql_num_rows ($rs); The number of rows affected, originally used MYSQL_FETCH_ASSOC
echo "$ASSOC";
$row =mysql_fetch_array ($RS); Just add back to this line.
if (! $rs) {die ("Valid result!");}
}
?>
Line |
Center number |
Line |
Vehicle self-numbering |
Transmission mode |
Media version |
Date |
Time |
State |
do {?>
|
|
|
|
|
|
|
|
|
$q = "SELECT *" from the "where Banben like '%{$_request[' Banben ']}% ' and linename like '%{$_request[' Xianlu ']}% ' and Z Huangtai like '%{$_request[' Zhuangtai ']}% ' ORDER by busname ASC ';
$_request[' Banben '],$_request[' Xianlu '],$_request[' Zhuangtai '] make corresponding judgments
Such as:
$sqlstr = "";
if (!empty ($_request[' Banben ')) {
$sqlstr = "and banben like '%{$_request[' banben ']}% '";
}
if (!empty ($_request[' Xianlu ')) {
$sqlstr. = "Linename like '%{$_request[' Xianlu ']}% '";
}
Similarly $_request[' Zhuangtai ']
$q = "SELECT * from the" where 1 = 1 $sqlstr ORDER by busname ASC ";
if (!empty ($_request[' Xianlu ')) {
$sqlstr. = "and linename like '%{$_request[' Xianlu ']}% '";
}
Now the problem is basically solved, but run a mistake, but not delay, how can let him not show ah
The 81st line of code is:
The complete code is as follows:
Data query
if ($_request[' Submit ']!= "")
{
$link =mysql_connect ("127.0.0.1", "root", "12345678");
if (! $link) echo "Not connected successfully!";
else echo "connected successfully!";
mysql_select_db ("Busap", $link); Select Database
Control query criteria
$q = "SELECT *" from the "where Banben like '%{$_request[' Banben ']}% ' and linename like '%{$_request[' Xianlu ']}% ' and Z Huangtai like '%{$_request[' Zhuangtai ']}% ' ORDER by busname ASC ';
mysql_query ("SET NAMES GB2312"); Prevent garbled characters
$rs = mysql_query ($q); Get Data Set
$ASSOC = mysql_num_rows ($rs); The number of rows affected, originally used MYSQL_FETCH_ASSOC
echo "$ASSOC";
$row =mysql_fetch_array ($RS); Just add back to this line.
if (! $rs) {die ("Valid result!");}
}
?>
Line |
Center number |
Line |
Vehicle self-numbering |
Transmission mode |
Media version |
Date |
Time |
State |
do {?>
|
|
|
|
|
|
|
|
|
Mysql_fetch_array, just add a judgment.
How to add judgment, novice, not