使用php怎么从数据表中读取数据到数组

使用php怎么从数据表中读取数据到数组

本篇文章给大家分享的是有关使用php怎么从数据表中读取数据到数组,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

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 will 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
}
?>

以上就是使用php怎么从数据表中读取数据到数组,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。