Print table data mysql php

Posted by Marcelo on Stack Overflow See other posts from Stack Overflow or by Marcelo
Published on 2010-06-10T11:15:29Z Indexed on 2010/06/10 11:33 UTC
Read the original article Hit count: 157

Filed under:
|
|
|
|

Hi people, i'm having a problem trying to print some data of a table. I'm new at this php mysql stuff but i think my code is right. Here it is:

<html>
<body>
<h1>Lista de usuários</h1>
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="sabs"; // Database name
$tbl_name="doador"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
while($rows = mysql_fetch_array($result)){
  echo $row['id'] . " " .$row['nome'] . " " . $row['sobrenome'] . " " . 
       $row['email'] . " " . $row['login'] . " " . $row['senha'] . " " . 
       $row['idade'] . " ". $row['peso'] . " " . $row['fuma'] . " " .
       $row['sexo'] . " " . $row['doencas'];
  echo "<BR/>";
}
mysql_close();
?>

</body>
</html>

All columns of the echo command exist in my table in the database. Don't get why it's not printing those values.

Thanks for the attention.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql