This article mainly introduces the PHP implementation of the general data from the database table reading to the array of functions, examples of PHP implementation of common database query skills, very practical value, the need for friends can refer to the next
In this paper, we describe a common PHP implementation function that reads data from a database table to an array. The specific analysis is as follows:
This function does not care about the table structure, but it is useful to specify the table name, structure, and query criteria to perform common query operations on the table.
function Listmytablerows ($table, $name, $field, $where, $textID) {//Connect to the database and query Executionconnect () ; $Sql = "select * from". $table. "". $where. "ORDER by". $field; $Req = mysql_query ($sql); $Res = Mysql_num_rows ($req);? ><select name = "<?php echo $name;?>" id= "<?php echo $textID;?>" ><option value= "> ____</ option><? php//We do a loops that would read the information for each recordwhile ($data = mysql_fetch_array ($res)) { //We DISP Lay the information from the current record?> <option value = "<?php echo $data [' id '];?>" > <?ph P echo $data [$field];? ></option> <? PHP }?></select><? Php}?>
Summary : The above is the entire content of this article, I hope to be able to help you learn.