This article describes the PHP implementation of the universal reading data from the database table to the array function. Share to everyone for your reference. The specific analysis is as follows:
This function does not care about the table structure, but it is useful to specify that the table name, structure, and query criteria can be used for common query operations on the table.
function Listmytablerows ($table, $name, $field, $where, $textID)
{
//Connect to the database and query execution
Connect ();
$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 loop that'll read the information for each record while
($data = mysql_fetch_array ($res))
{
//We display the information from the current record
?>
<option value = "<?php echo $data [' ID '];?> ">
<?php echo $data [$field];?>
</option>
PHP
}
?>
</select>
. PHP
}
?>
I hope this article will help you with your PHP program design.