Hi, I’ve looked at the site you showed me previously (tutsplus) and used their example to display my information from the database. However, it also displays some excessive numbers and letters. Currently, using your example, if I visit www.site.com/restaurant.php?id=1 , nothing will show in my content part.
Here’s the code(without passwords):
<?php
$hostname = "localhost";
$db_user = "user";
$db_password = ""
$database = "db";
$db_table = "review"; // leave this as is
$db = mysql_connect($hostname, $db_user, $db_password);
$page_title=$rows['name'];
$id=$rows['id'];
$dname=$rows['name'];
?>
<!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>foodhouse|<?php echo $page_title; ?></title>
<link rel="icon" type="image/png" href="favicon.png" />
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="js/jquery-1.7.min.js"> </script>
<script type="text/javascript" src="js/jquery-ui-1.8.12.min.js"> </script>
<script type='text/javascript' src='/js/lib/mootools-core-1.3-full-compat-nc.js'></script>
<script type="text/javascript">
function Toggle(id,close,open,ms){
var obj=document.getElementById(id),o=Toggle['zxc'+id],to;
if (!o&&obj){
Toggle['zxc'+id]=o={
obj:obj,
now:0,
ms:500,
ud:true
}
}
if (o){
ms=typeof(ms)=='number'?ms:o.ms;
obj.style.display='block';
to=o.ud?open:close;
clearTimeout(o.dly);
animate(o,o.now,to,new Date(),ms*Math.abs((to-o.now)/open));
o.ud=!o.ud;
}
}
function animate(o,f,t,srt,mS){
var oop=this,ms=new Date().getTime()-srt,now=(t-f)/mS*ms+f;
if (isFinite(now)){
o.now=Math.max(now,0);
o.obj.style.height=o.now+'px';
}
if (ms<mS){
o.dly=setTimeout(function(){ oop.animate(o,f,t,srt,mS); },10);
}
else {
o.now=t;
o.obj.style.height=o.now+'px';
if (t==0){
o.obj.style.display='none';
}
}
}
</script>
<script type="text/javascript">
animatedcollapse.addDiv('jason', 'optional_attribute_string')
//additional addDiv() call...
//additional addDiv() call...
animatedcollapse.init()
</script>
<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="contain">
<div id="header">
<div id="hwrapper">
<a href="#" id="logo"><img src="flogo.png" alt="Logo" width="460px" height="140px"/></a>
</div>
</div>
<div id="container">
<div id="line">
</div>
<div id="navbar">
<div id="nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">List</a></li>
<li><a href="#">Submit</a></li>
<li><a href="#">About</a></li>
<li><a href="#"><div class="button open-button" onMouseUp="Toggle('page-split-wrap',0,250,500);"><span style="font-style:italic; font-size:19px;">Restaurant Search</span></div></a>
</li>
</ul>
</div>
<div id="body">
<div id="page-split-wrap">
<div class="page-split-head"> </div>
<div class="page-split-content">
<p class="inside">Content in here</p>
<p class="inside">Content in here</p>
</div>
</div>
<div id="wrapperb">
<?php
$id = $_GET['id'];
// Connect to db
try
{
$pdo = new PDO('mysql:host=localhost;dbname=db', 'user', 'pw');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
}
catch (PDOException $e)
{
echo "Unable to connect to the database server!<br>" . $e;
exit();
}
// The query
$sql= $pdo->prepare('SELECT * FROM review WHERE id = :id');
$sql->execute(array(':id' => $id));
// Do something with result
foreach ($sql as $row) {
echo $row['text'];
}
?>
</div>
</body>
</html>