Yêu cầu thg 6 20, 2018 6:32 SA 110 0 1
  • 110 0 1
0

Cần trợ giúp class php

Chia sẻ
  • 110 0 1

Mình chuyển qua tổng hợp class database chứa thông tin kết nối MySQLi với toàn bộ function, nhưng khi file POST.php mình

if(isset($_POST['ok']))
{
	$id=$_POST['answer'];
	$sql="update answer set acount=acount + 1 where aid='".$id."'";
	mysqli_query($conn,$sql);
	header("location: poll.php");
	exit();
}

thì lại không hoạt động chức năng lưu vào mysql, mình cần trợ giúp làm sao lưu

1 CÂU TRẢ LỜI


Đã trả lời thg 6 20, 2018 6:50 SA
+1

có vẻ trong <form method="POST"> đang thiếu action , chắc ý bạn là action="POST.php"

Chia sẻ
thg 6 20, 2018 7:05 SA

trong index.php mình viết vậy

<form method='post'> <?php $db->VOTED(); ?> </form> trong $db->VOTED(); thì if(mysqli_num_rows($answer)>0){ while($row=mysqli_fetch_array($answer)){ $percent=round(($row['acount']/$total)*100,2); echo "
  • <span class='perc-back' style='width: $percent%'></span> <input type='radio' name='answer' value=$row[aid]> <label for='answer'>$row[atitle]</label> <span class='perc-number'>$percent%</span>
  • "; } } echo "<button type='submit' name='ok'>Bình chọn</button>"; do mình chuyển qua class thì mới error cái mysqli_query($conn,$sql); mình không biết chỉnh phần đó
    Viblo
    Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
    Đăng kí