What I do is a graduation design topic system, now in the familiar code. I know which function is implemented by which code, but I am very vague about the specific meaning of the code. Looking for a master to help me in the next note in the rear ~ ~
Since my project is old based on modifying some of the added features, it is sometimes necessary to add
Extract ($_post);
Or
Extract ($_request);
To run some features, what does that mean?
Also, I have to follow a few sentences behind every code that executes the database.
$query = "SELECT * from $student _table where xuehao= ' $xuehao '"; mysql_query ("Set names ' GB2312 '"); $result =mysql_query ($ query); $row =mysql_fetch_array ($result);
And this is a part of revising the subject, I don't know what SN and ssn are for.
$query = "Select number as sn,surplus as SSN from $keti _table where id= ' $id '"; mysql_query ("Set names ' gb2312 '"); $result =mysql_query ($query); $row =mysql_fetch_array ($result), if ($number 1< $row [' SN ']) {if ($number 1< ($row [' SN ']-$row [' ssn ']) {echo "the number of people can not be less than the number of selected topics, the number of changes failed! "; echo"
"; exit;} else{$query 2=mysql_query ("Update $keti _table set number= ' $newnumber ' where id= ' $id '"); $query 3=mysql_query ("Update $ Keti_table set surplus=surplus-($row [sn]-$newnumber) where id= ' $id ' "); mysql_query (" Set names ' gb2312 ' "); $result 1=mysql_query ($query 3);}} else{$query 4=mysql_query ("Update $keti _table set number= ' $newnumber ' where id= ' $id '"); $query 5=mysql_query ("Update $ Keti_table Set surplus=surplus+ ($newnumber-$row [SN]) where id= ' $id ' "); mysql_query (" Set names ' gb2312 ' "); $result 2=mysql_query ($query 5); }if ($result ==true) {echo "
Modify the project success! "; echo "
"; Exit }
This is a piece of code to download the material
$file _name= "related information. rar"; $file _dir= "temp/./"; if (!file_exists ($file _dir. $file _name)) { echo "The file could not be found
"; echo "
"; Exit; } else{ $file =fopen ($file _dir $file _name, "R");//Open File Header ("Content-type:application/octet-stream"); Header ("Accept-ranges:bytes"); Header ("Accept-length:". FileSize ($file _dir. $file _name)); Header ("content-disposition:attachment; Filename= ". $file _name); ReadFile ($file _dir. $file _name); }
In particular, the last one on the "optional" and "not selectable" forms, do not understand
$surplus = "; Extract ($_request); $n =0; if (empty ($offset)) {$offset =0;} mysql_query ("Set names ' GB2312 '"); $where = (isset ($surplus) && strlen ($surplus) >0)? "Where surplus= ' $surplus '": '; Don't know ... $query =mysql_query ("SELECT count (*) as SM from Keti $where"); $row =mysql_fetch_array ($query); $count = $row [' SM ']; The total number of records $query =mysql_query ("select * from Keti $where the ORDER by ID ASC limit $offset, $list _num") or Die ("fail");
Reply to discussion (solution)
Extract importing an array into the variable table (the association key is the variable name)
mysql_query ("Set names ' GB2312 '"); Used to notify MySQL of future interactions with the GB2312 character set
It's usually done once after connecting to the database.
By
if ($number 1< ($row [' SN ']-$row [' ssn ']) {
Echo
the number of people can not be less than the number of selected topics, the number of changes failed! ";
SN is an alternative number, SSN selected
No filter criteria Query
Select COUNT (*) as SM from Keti
Query with filter conditions
Select COUNT (*) as SM from Keti where surplus= ' $surplus '
Extract importing an array into the variable table (the association key is the variable name)
mysql_query ("Set names ' GB2312 '"); Used to notify MySQL of future interactions with the GB2312 character set
It's usually done once after connecting to the database.
By
if ($number 1< ($row [' SN ']-$row [' ssn ']) {
Echo
the number of people can not be less than the number of selected topics, the number of changes failed! ";
SN is an alternative number, SSN selected
No filter criteria Query
Select COUNT (*) as SM from Keti
Query with filter conditions
Select COUNT (*) as SM from Keti where surplus= ' $surplus '
This is the last sentence to understand
$where = (isset ($surplus) && strlen ($surplus) >0)? "Where surplus= ' $surplus '": ';
Ternary operations, equivalent to
if (Isset ($surplus) && strlen ($surplus) >0)) {
$where = "where surplus= ' $surplus '";
}else {
$where = ";
}