kadamabhijeet_91 Posted December 26, 2008 Share Posted December 26, 2008 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> Link to comment https://forums.phpfreaks.com/topic/138443-displaying-the-database-in-browser-using-php/ Share on other sites More sharing options...
.josh Posted December 26, 2008 Share Posted December 26, 2008 be more specific than "it's not working" Link to comment https://forums.phpfreaks.com/topic/138443-displaying-the-database-in-browser-using-php/#findComment-723853 Share on other sites More sharing options...
kadamabhijeet_91 Posted December 26, 2008 Author Share Posted December 26, 2008 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 Link to comment https://forums.phpfreaks.com/topic/138443-displaying-the-database-in-browser-using-php/#findComment-723856 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.