Jump to content

[SOLVED] Pulling info from database and displaying in database


herghost

Recommended Posts

Hi all,

 

heres my code:

 

<?php
include('../include/dbconnect.php');
?>

<p> Welcome to the solutions center. Here you can view all problems and answers posted on the website. These are arranged by category. Please click on the post title to view that post</p>
<br>
<h3>Last 10 Posts</h3></p>
<table>
			<tr>
				<th><strong>Post</strong> Date</th>
				<th width="20%">Category</th>
				<th width="40%">Title</th>
                    <th>Views</th>
                  <th>Replies</th>
			</tr>
               <?php $query="SELECT * FROM forum_question ORDER BY id DESC LIMIT 10";
			$result=mysql_query($query) or die ("fucked" .mysql_error()); 
			while($rows=mysql_fetch_array($result))
			{
				?>
                <tr><? echo $rows['datetime']; ?></tr>
                <tr><? echo $rows['cat']; ?></tr>
                <tr><? echo $rows['title']; ?></tr>
                <tr><? echo $rows['views']; ?></tr>
                <tr><? echo $rows['replies']; ?></tr>
                
                <?php } ?>
</table>

 

Now while the table itsself appears (I can see the TH's) No data is filling the table, the data exist in the database but is not posting in the table? No errors to report on screen. ANy ideas?

 

Thanks

When you do a "view source" of the page in your browser, what do you see?

 

If you see the raw php code - <? echo $rows['datetime']; ?>, then please, please, please only use full opening php tags <?php as the short open tag <? is not always enabled and you won't always be on a server where you will have the ability to enable them.

Well, this is more of an HTML problem...

You don't have table cells "<TD>".

 

Try this:

                <tr>
                <td><? echo $rows['datetime']; ?></td>
                <td><? echo $rows['cat']; ?></td>
                <td><? echo $rows['title']; ?></td>
                <td><? echo $rows['views']; ?></td>
                <td><? echo $rows['replies']; ?></td>
                </tr>

 

Hope this helps,

Handy PHP

Damn,

 

thanks to both of you, I didn't even reliase id gone back into short tags.... I turned them off a good two years ago, quick memory slip me thinks!

 

and thanks for the basic html lesson :) Once the fingers get going its hard to stop them.... :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.