snefmoo
04-17-2009, 07:25 PM
im trying to get an array of information from my database and post each record into a separate table for a guestbook. iv got it working so the data is added to the database but cant seem to get the array working to show the data.
Heres my code for the viewguestbook page:
<?php
$host="localhost";
$username="root";
$password="";
$db_name="mywebsite";
$tbl_name="guestbook";
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
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));
?>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><div align="left"><strong><span class="style1">View Guestbook | <a href="guestbook.php">Sign Guestbook</a></span> </strong></div></td>
</tr>
</table>
<center> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#c4c2c2">
<tr>
<td width="117"><span class="style1">Name</span></td>
<td width="14">:</td>
<td width="357"><?php echo $rows['name']; ?></td>
</tr>
<tr>
<td><span class="style1">Email</span></td>
<td>:</td>
<td><?php echo $rows['email']; ?></td>
</tr>
<tr>
<td valign="top"><span class="style1">Comment</span></td>
<td valign="top">:</td>
<td><?php echo $rows['comment']; ?></td>
</tr>
<tr>
<td height="25" valign="top"><span class="style1">Date/Time </span></td>
<td valign="top">:</td>
<td><?php echo $rows['datetime']; ?></td>
</tr>
</table>
<br></center></div>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
</tr>
</table>
<BR>
<?php
mysql_close();
?>
any pointers would be really appreciated as it is for my dissertation which is due in soon and this is all i need to complete my work. :)
Heres my code for the viewguestbook page:
<?php
$host="localhost";
$username="root";
$password="";
$db_name="mywebsite";
$tbl_name="guestbook";
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
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));
?>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><div align="left"><strong><span class="style1">View Guestbook | <a href="guestbook.php">Sign Guestbook</a></span> </strong></div></td>
</tr>
</table>
<center> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#c4c2c2">
<tr>
<td width="117"><span class="style1">Name</span></td>
<td width="14">:</td>
<td width="357"><?php echo $rows['name']; ?></td>
</tr>
<tr>
<td><span class="style1">Email</span></td>
<td>:</td>
<td><?php echo $rows['email']; ?></td>
</tr>
<tr>
<td valign="top"><span class="style1">Comment</span></td>
<td valign="top">:</td>
<td><?php echo $rows['comment']; ?></td>
</tr>
<tr>
<td height="25" valign="top"><span class="style1">Date/Time </span></td>
<td valign="top">:</td>
<td><?php echo $rows['datetime']; ?></td>
</tr>
</table>
<br></center></div>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
</tr>
</table>
<BR>
<?php
mysql_close();
?>
any pointers would be really appreciated as it is for my dissertation which is due in soon and this is all i need to complete my work. :)