-1

This doesn't work:

// Extract data items from dataset

I've been all over the web for two days, including previous answers here

    if ($result-> num_rows > 0)
        {
        while($row = $result-> fetch_assoc())

Connected successfully Notice: Undefined property: PDOStatement::$num_rows in E:\web\peoplespoll\htdocs\TableTest.php on line 64 0 result Fatal error: Uncaught Error: Call to undefined method PDO::close() in E:\web\peoplespoll\htdocs\TableTest.php:83 Stack trace: #0 {main} thrown in E:\web\peoplespoll\htdocs\TableTest.php on line 83

Parker
  • 11
  • 1
  • 3
  • if ($result-> num_rows > 0) { while($row = $result-> fetch_assoc()) { echo " " . $row["description"]. " " . $row["voteyes"] . " " . $row["voteno"] . " " . $row["votehuh"] . " "; } echo ""; } else { echo "0 result"; } – Parker Oct 03 '19 at 20:37

1 Answers1

2

You're trying to use mysqli syntax, but you're using PDO. It should be:

if ($result->rowCount() > 0){
    while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
        // Do stuff
    }
}
Kossi
  • 77
  • 2
  • 10
Barmar
  • 741,623
  • 53
  • 500
  • 612