problem to display data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bella1010
Forum Newbie
Posts: 12
Joined: Fri Apr 01, 2011 11:03 am

problem to display data

Post by bella1010 »

problem: cannot display my inserted data. every thing work well. the only problem face is no output display ... why? software used was dreamweaver. below coding is PHP embed HTML. is the problem i embed the PHP into HTML with wrong display coding? <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<form id="form2" name="form2" method="post" action="">
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="22222222"; // Mysql password
$db_name="ssss"; // Database name
$tbl_name="vrpost"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
?>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="6%" align="center" bgcolor="#E6E6E6"><strong>ID</strong></td>
<td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){ // Start looping table row
?>
<tr>
<td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
</tr>

<?php
// Exit looping and close connection
}
mysql_close();
?>
<tr>
<td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong></table>

</tr>
</table>
</form>
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: problem to display data

Post by McInfo »

Please use syntax BBCode tags when posting code. There is a "PHP Code" button on the posting form.

Try using full PHP tags in your script (<?php). Your server is probably configured to disallow short open tags via the short_open_tag directive in php.ini.
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: problem to display data

Post by fugix »

yeah most likely you do not have short tags=true. get into the habit of using full tags like mcinfo said. try to change the tags and let us know if your problem persists
bella1010
Forum Newbie
Posts: 12
Joined: Fri Apr 01, 2011 11:03 am

Re: problem to display data

Post by bella1010 »

problem was solve by using full php tags (<?php). thanks~ ^^
Post Reply