I KNOW this has been asked already but nothing seems to work for my problem. I need to get some data from the database and display it in the HTML.
The code is thus:
<?php
$host="localhost"; // Host name
$username="bluecode_power"; // Mysql username
$password="bluecode123"; // Mysql password
$db_name="bluecode_login"; // Database name
$tbl_name="news"; // Table name
$myConnection= mysqli_connect("$host", "$date", "$user", "$title", "$text")or die("cannot connect");
mysqli_select_db("$db_name")or die("cannot select database");
$query = "SELECT * FROM news"; //You don't need a ; like you do in SQL
$result = mysql_query($query);
echo "<table>"; // start a table tag in the HTML
while($row = mysql_fetch_array($result)){ //Creates a loop to loop through results
echo "<tr><td>" . $row['date'] . "</td><td>" . $row['news'] . "</td></tr>"; //$row['index'] the index here is a field name
}
echo "</table>"; //Close the table in HTML
mysql_close();
?>
Thanks for any ideas :)