你好,我有一个问题,我看不到文章a1我认为我有一个错误,我认为问题是在if isset帖子...
`<input type="button" name="g1" value="click">
<?php
try{
$db = new PDO('mysql:host=localhost;dbname=search','root','');
}catch(PDOexeption $e){
echo "erreur 404";
}
if(isset($_POST['g1'])){
$insert = $db->exec("UPDATE g2 SET a1 = a1 + 1 WHERE id = '15'");
$query = $db->query("SELECT * FROM g2");
while($article = $query->fetch())
{
echo $article['a1'];
}
};
?>'
答案 0 :(得分:0)
如果我理解正确您正在尝试从表单发送输入值,请使用此方法。 HTML PART
<form action="#" method="post">
<input type="submit" name="g1" value="Click" />
</form>
PHP SIDE:
try{
$db = new PDO('mysql:host=localhost;dbname=search','root','');
}catch(PDOexeption $e){
echo "erreur 404";
}
if(isset($_POST['g1'])){
$insert = $db->prepare("UPDATE g2 SET a1 = a1 + 1 WHERE id = '15'");
$exe = $insert->exe();
$query = $db->prepare("SELECT * FROM g2");
$sel = $query->exe();
foreach ($query as $select) {
echo $select['a1'];
}
};
我希望它能帮到你