-2

I'm beginner in php and html so I need your help. I am trying to display data from my sql database created using phpmyadmin , to a php page.

I've searched the internet and found similar topics , but still have problems

DB: wban ...

Table name: Jack ...

columns to be displayed: Temprature ,pulse , Motion ...

Here is my code , a blank page appear when request "localhost/Jack.php"

<?php

$conn=mysql_connect('localhost', 'root', 'MYPASSWORD'); 
mysql_select_db('wban');


   if(! $conn ) {
  die('Could not connect: ' . mysql_error());
         }

$query = "SELECT * FROM Jack"; 
$result = mysql_query($query);

?>

<html>
<head> <title> Jack Status </title> </head>
<body>

<table width="600" border="1" cellpadding="1" cellspacing="1">
<tr> <!-- header row -->
<th>Data</th>
<th>Latest Readings</th>
<th>Average</th>
<th>Standard Deviation</th>
<th>Condition</th>
</tr>

<?php

while($row = mysql_fetch_assoc($result)){   //Create a loop to loop through results
    echo "<tr>"
    echo "<td>.$row['Temprature'].</td>"    
    echo "<td>.$row['Pulse'].</td>"
    echo "<td>.$row['Motion'].</td>"
    echo "</tr>"
   }//end while
mysql_close(); //close out the database connection
?>
</table>
</body>
</html>
Areej Qadomi
  • 143
  • 1
  • 1
  • 14

1 Answers1

2

Make sure you close every php statement with matching quotes and at the end of the statement you must add a semicolon.

The dot operator does not work within a string literal, so close double quotes each time you need to apply that operator, like this:

<?php

while($row = mysql_fetch_assoc($result)){   //Create a loop to loop through results
echo "<tr>";
echo "<td>".$row['Temprature']."</td>";  
echo "<td>".$row['Pulse']."</td>";
echo "<td>".$row['Motion']."</td>";
echo "</tr>";
}//end while
mysql_close(); //close out the database connection
?>
Indrajit
  • 405
  • 4
  • 12