I want to link MySQL DB to the HTML and get the data according to the query below.

SELECT * FROM feature1 WHERE place = 'feature2'

php seems one of the way to do this, since I am one day old with php don't have much knowledge. I wrote the code below, but when run it gives me an error with no solid output. Is the code correct?

I want to query the DB using the above query and display data!!

$db = mysqli_connect('localhost','user','password','DB_name')
or die('Error connecting to MySQL server.');

> $query = "SELECT * FROM feature1";

mysqli_query($db, $query) or die('Error querying database..');
$result = mysqli_query($db, $query);
$row = mysqli_fetch_array($result);
while ($rows = mysql_fetch_array($query)) { 
   $name = $rows['Name'];
   $address = $rows['Address'];
   $email = $rows['Email']

   echo "$name<br>$address<br>$email<br>$subject<br>$comment<br><br>";  


  • if using php you need to pull the data out a database and turn it into a html friendly format (xml/json) like this > stackoverflow.com/questions/5112282/… – Mapperz Apr 1 at 16:38
  • Yes will try that thanks. – user139697 Apr 3 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy