Error Appears When Trying to Display MySQL Table Data in HTML Table

Kelsey

I am trying to display a MySQL Table on my PHP page. The Table headers appear correctly but none of the MySQL table rows are appearing, and an error is also appearing where the MySQL table row data should appear. I am getting this error when I run my PHP page:

Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in /home/www/s.com/yogaclub/index.php on line 61

This is the code to my page:

   <?php
$username = "d";
$password = "dar";
$hostname = "localhost"; 

//connection to the database
$con = mysqli_connect($hostname, $username, $password) 
  or die("Unable to connect to MySQL");

if ($con) { } else { echo "didn't work";} 
?>

<!doctype html>
<head>
<style>
body {
    font-family:verdana;
}

#box {
    background-color:yellow;
    position:relative;
    color:red;
    padding-top:10px;
    margin:auto;
    width:600px;
    border-radius:15px
    padding-bottom:10px;    
}

    .container {
        width: 500px;
        clear: both;
    }
    .container input {
        width: 100%;
        clear: both;
    }


#pic {
    align:left
}
</style>    
<title>Yoga Club</title>
</head>
<body bgcolor="blue">
<div id="box">
<h3><center>Yoga Club!</center></h3>
<img src="thOX7T2TIR.jpg" id="pic"><span style="text-align:center; align:right"><span style="color:blue;"></span>
<?php 

$result = mysqli_query($con, "SELECT * FROM yogaclub");

echo "<table border='1'>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>";

while($row = mysqli_fetch_row($result))
{
echo "<tr>";
echo "<td>" . $row['fname'] . "</td>";
echo "<td>" . $row['lname'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysqli_close($con);
?><br /><br /><center>Please Sign up to the Adventures of Yoga.
We will be doing lots of different kinds of stretches.</center>
<?php /* if(isset($_POST['add']))
{ 
$sql = mysql_query("insert into yogaclub(fname, lname) values('$_GET['fname']', '$_GET['lname']')"); 
} else { echo "nonsend"; } */
?><br /><form method="post" action="<?php $_PHP_SELF ?>">First Name: <input name="fname" type="text"><Br />Last Name: <input type="text"><br />Address: <input type="text"><br />Email: <input type="text"><br />Phone Number: <input type="text"><input type="hidden" value="send" name="send"><br />Yoga Experience: <select>
   <option value="none">None</option>
   <option value="alittle">A little</option>
   <option value="alot">A lot</option>
</select> <br />Age: <input type="text" size="3"><br /><br />
<input type="submit" name="add" value="Sign me up!"></form></span>
</div>
</body>
</html>

All help is greatly appreciated.

Chit Min Thu

Instead of

while($row = mysqli_fetch_row($result))

please try to test with

while($row= mysqli_fetch_assoc($result))

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Display mysql table data in PHP

분류에서Dev

How to display data for a certain period of time (day / week / month) from Mysql table in html table (php)

분류에서Dev

Trying to join multiple tables in MySQL database and display in Web Table

분류에서Dev

Mysql views return data when table empty

분류에서Dev

error when I try to fill table with data

분류에서Dev

Runtime error when I trying to connect to database table

분류에서Dev

Display data in HTML table or DataTable depending on radio button selection

분류에서Dev

Getting SUM of MySQL table data when there is floating point numbers

분류에서Dev

How can I select data from a mysql table, and then throw it into a html table

분류에서Dev

PHP/MySql HTML Table Grouping

분류에서Dev

insert form data into mysql table

분류에서Dev

TASM 8086 Trying Counting Count the characters of a string and display them in a table

분류에서Dev

echo MySQL table to HTML table displaying text for null fields

분류에서Dev

PHP function giving me exception when trying to display on HTML

분류에서Dev

How to resolve error when trying to open Windows Display Settings?

분류에서Dev

Select table from Sql server and insert data to Mysql table

분류에서Dev

MySQL Workbench Error 1005 cant create table

분류에서Dev

How to select data from columns in only one table when checking two tables limited by where clause in MySQL

분류에서Dev

Proper way to insert data into table with php and mysql?

분류에서Dev

MySQL query, sum data from table

분류에서Dev

Is it possible to shift column data downwards in a MySQL table?

분류에서Dev

How to properly search for data in a MySQL table

분류에서Dev

Trying to get column data from pivot table laravel

분류에서Dev

update html table when dropdown value change

분류에서Dev

Displaying data based on checkboxes selection to html table

분류에서Dev

Formating Mail Body data into html table format

분류에서Dev

Displaying XML file data in a HTML table

분류에서Dev

Error when creating table with mysqldb module

분류에서Dev

Error when testing for the max value of a table?

Related 관련 기사

  1. 1

    Display mysql table data in PHP

  2. 2

    How to display data for a certain period of time (day / week / month) from Mysql table in html table (php)

  3. 3

    Trying to join multiple tables in MySQL database and display in Web Table

  4. 4

    Mysql views return data when table empty

  5. 5

    error when I try to fill table with data

  6. 6

    Runtime error when I trying to connect to database table

  7. 7

    Display data in HTML table or DataTable depending on radio button selection

  8. 8

    Getting SUM of MySQL table data when there is floating point numbers

  9. 9

    How can I select data from a mysql table, and then throw it into a html table

  10. 10

    PHP/MySql HTML Table Grouping

  11. 11

    insert form data into mysql table

  12. 12

    TASM 8086 Trying Counting Count the characters of a string and display them in a table

  13. 13

    echo MySQL table to HTML table displaying text for null fields

  14. 14

    PHP function giving me exception when trying to display on HTML

  15. 15

    How to resolve error when trying to open Windows Display Settings?

  16. 16

    Select table from Sql server and insert data to Mysql table

  17. 17

    MySQL Workbench Error 1005 cant create table

  18. 18

    How to select data from columns in only one table when checking two tables limited by where clause in MySQL

  19. 19

    Proper way to insert data into table with php and mysql?

  20. 20

    MySQL query, sum data from table

  21. 21

    Is it possible to shift column data downwards in a MySQL table?

  22. 22

    How to properly search for data in a MySQL table

  23. 23

    Trying to get column data from pivot table laravel

  24. 24

    update html table when dropdown value change

  25. 25

    Displaying data based on checkboxes selection to html table

  26. 26

    Formating Mail Body data into html table format

  27. 27

    Displaying XML file data in a HTML table

  28. 28

    Error when creating table with mysqldb module

  29. 29

    Error when testing for the max value of a table?

뜨겁다태그

보관