用php更新sql查询

时间:2016-06-06 01:06:05

标签: php ajax postgresql

我的表名是main_info。页面已加载查询将工作,它将创建一个html表,并将行值写入表。我想获得idseq列的下一个值。首先我得到了id_seq = 5。后来我想用一个按钮获得id_seq = 6的下一个值。我想用ajax更新我的查询,但我做不到。我希望你知道我的意思。 Plz的帮助。

<html>
<head>
    <title>Test</title>
    <meta charset="UTF-8">
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
   <?php 
    include '../config.php';
    $var=5;
    $query="SELECT city, city_x, page_title, page_url, price, 
    date, situation, img, source FROM main_info where id_seq=$var";  
    $result = pg_exec($link, $query);
    $numrows = pg_numrows($result);
    echo  '<table border="1">
        <tr> 
            <th>id_seq</th>
            <th>city</th>
            <th>page_url</th>
        </tr>  ';
    while ($row = pg_fetch_assoc($result)) {
    $id_seq = $row['id_seq'];
    $city= $row['city']; 
    $page_url= $row['page_url']; 
echo "<td>$id_seq</td><td>$city</td><td>$page_url</td></tr>";       
    }
   pg_close($link);
   echo '</table>';
?> 
    <button'>next_item</button>
</body>
</html> 

0 个答案:

没有答案