时间:2021-07-01 10:21:17 帮助过:21人阅读
?Array ( [0] => Array ( [myname] => 魏亮 ) [1] => Array ( [myname] => 宋向东 ) [2] => Array ( [myname] => 王克娇 ) [3] => Array ( [myname] => 刘彦宾 ) [4] => Array ( [myname] => 程秀芹 ) [5] => Array ( [myname] => 李国振 ) )
$sql = "select myname from xs_staff";$js = get_array($sql);print_r($js);
function get_array($sql){ $result = mysql_query($sql); $arr = array(); while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $arr[] = $row; } mysql_free_result($result); mysql_close($conn); return $arr; }
你那是二维数组
echo $js[0]['name'];
就可以了。注意第一维的下标从 0 到 count($js) - 1