Jump to content

Recommended Posts

Hi all i need help!

 

I am trying to create a table of 10 latest posts from my forums on the first page of my site. I have tried the following code but errors occur:

 

<h1>LAST 10 POSTS</h1>

<table border=\"1\">

<tr>

<td class=\"white\"><strong>Topic ID</strong></td>

<td class=\"white\"><strong>Topic Title</strong></td>

<td class=\"white\"><strong>Topic Time</strong></td>

<td class=\"white\"><strong>Topic Views</strong></td>

<td class=\"white\"><strong>Forum ID</strong></td>

<td class=\"white\"><strong>Forum Name</strong></td>

<td class=\"white\"><strong>User Name</strong></td>

</tr>

<?php

mysql_pconnect(\"localhost\",\"***\",\"***\");

$query=\"SELECT topic_id, topic_title, topic_time, topic_views, t.forum_id, f.forum_name, u.uname FROM \".$mpnTables.\" t, \".$mpnTables.\" f, \".$mpnTables.\" u where (f.forum_id=t.forum_id) and (forum_type \'1\') and (t.last_post=u.uid) ORDER BY topic_time desc LIMIT 10\";

$result=mysql_db_query(\"***\",$query);

while($row=mysql_fetch_row($result)){

?>

<tr>

<td class=\"white\"><?php print($row[0]);?></td>

<td class=\"white\"><?php print($row[1]);?></td>

<td class=\"white\"><?php print($row[2]);?></td>

<td class=\"white\"><?php print($row[3]);?></td>

<td class=\"white\"><?php print($row[4]);?></td>

<td class=\"white\"><?php print($row[5]);?></td>

<td class=\"white\"><?php print($row[6]);?></td>

</tr>

<?php

}

mysql_free_result($result);

?>

</table>

 

Gives following errors:

 

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in ***/index2.php on line 170

 

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in ***/index2.php on line 183

 

Any suggestions anyone?

My tables are called: mpn_topics, mpn_forums,mpn_users.

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/1448-help-creating-a-table/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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