I am trying to learn how to incorporate SQL into PHP but I am having some difficulties. I'm not sure on the overall concept, i am trying to follow along in a book but its not helping too much. In a C programming class I took, when we scanned data in from a text file, we stored it into an array that we could use later. Does that work just as well for PHP? and if so whats some basic structure I could follow for that. Currently the book is telling me to do something like this:
<HTML>
<BODY>
<?PHP
$host = "localhost";
$user = "root";
$password = "root";
$dbname = "calendar";
$cxn = mysqli_connect($host, $user, $password, $dbname);
#$x = 0;
$query = "SELECT event FROM Calendar";
$result = mysqli_query($cxn, $query);
mysqli_data_seek($result, 0);
while($row = mysqli_fetch_row($result))
{
extract($row);
echo "<P>".$row[0]."</P>";
#$i[$x] = .$row[1].;
#echo $i[x];
#$x++;
}
?>
</HTML>
</BODY>
the commented lines is what I was trying to do but it gives me a parse error. Any ideas on how to do this? Any can anyone explain this whole concept to me? Thanks
<HTML>
<BODY>
<?PHP
$host = "localhost";
$user = "root";
$password = "root";
$dbname = "calendar";
$cxn = mysqli_connect($host, $user, $password, $dbname);
#$x = 0;
$query = "SELECT event FROM Calendar";
$result = mysqli_query($cxn, $query);
mysqli_data_seek($result, 0);
while($row = mysqli_fetch_row($result))
{
extract($row);
echo "<P>".$row[0]."</P>";
#$i[$x] = .$row[1].;
#echo $i[x];
#$x++;
}
?>
</HTML>
</BODY>
the commented lines is what I was trying to do but it gives me a parse error. Any ideas on how to do this? Any can anyone explain this whole concept to me? Thanks