Jump to content

Recommended Posts

i have created a database and i have inserted some values in it. now i want to

view the database from my browser .i have written code for it but it's not working.im attaching the code .pls help me.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'demojoomla';
$dbname = 'user';

mysql_pconnect("localhost", "root", "demojoomla")or die("cannot connect server ");
mysql_select_db("user")or die("cannot select DB");

$sql="SELECT * FROM user_tbl";
$result = mysql_query($sql) or die ("Query failed" . mysql_error());

echo "<table border = '1'>";
echo "<tr>";
echo "<th>ID</th><th>Name</th><th>Age</th><th>Gender</th><th>Username</th><th>Password</th><th>IPaddress</th>";
echo "</tr>";
while($rows = mysql_fetch_array($result));
{
echo "<tr>";
echo "<td>", $rows['id'], "</td><td>", $rows['name'], "</td><td>", $rows['age'], "</td><td>", $rows['gender'], "</td><td>", $rows['username'], "</td><td>", $rows['password'], "</td><td>",	 $rows['ipaddress'], "</td>";
echo "</tr>";
}
echo "</table>";

?>
</body>
</html>

I have changed the code in following format

 

  <?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'demojoomla';
$dbname = 'user';

mysql_pconnect("localhost", "root", "demojoomla")or die("cannot connect server ");
mysql_select_db("user")or die("cannot select DB");

$sql="SELECT * FROM user_tbl";
$result = mysql_query($sql) or die ("Query failed" . mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php 
<table width="751" height="80" border="1">
  <tr>
    <td>id</td>
    <td>name</td>
    <td>age</td>
    <td>gender</td>
    <td>username</td>
    <td>password</td>
    <td>ip</td>
  </tr>
  $user_details = '';
  while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$name = $row['name'];
$age = $row['age'];
$gender = $row['gender'];
$username = $row['username'];
$password = $row['password'];
$ip = $row['ip'];
$user_details .=<<<EOD
<p> </p>


  <tr>
    <td>$id</td>
    <td>$name</td>
    <td><$age</td>
    <td>$gender</td>
    <td>$username</td>
    <td>$password</td>
    <td>$ip</td>
  </tr>
  EOD;
  }
  
</table>
?>
</body>
</html>

 

When i preview the page...it shows nothing

 

The page remains blank

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.