Simple Ajax Jquery script- How can I get information for each of the rows in the table?

前端 未结 2 731
慢半拍i
慢半拍i 2020-12-16 04:56

I\'m following a simple ajax>php>mysql example posted here http://openenergymonitor.org/emon/node/107

I can only display information from the first row. My table is

2条回答
  •  旧巷少年郎
    2020-12-16 05:38

    $result = mysql_query("SELECT * FROM $tableName");
    $array = array(mysql_fetch_row($result));
    
    // To store every row in the $array
    while($row = mysql_fetch_row($result)) { 
        $array[] = $row; 
    } 
    echo json_encode($array);
    

提交回复
热议问题