Jump to content

Recommended Posts

I have this small piece of code here that i cannot get to work properly.

I have 2 tables that i need to retrieve information from.

 

The first is a table that holds posts and replies while the second is the user data holding all the membership details.

What i need to do is fetch all of the post information along with the author of the post so that i can display it. This works perfectly.

I then need to grab the post count of the user who posted so i can display it.

I need to somehow fetch the postcount of the username where username is the same as the author of the post.

 

I tried adding variable into the MYSQL query but it would not work and just output an "S" next to posts.

 

Here is the piece of code:

$gettopic="SELECT * from post_reply where postid='$id'";

$gettopic2=mysql_query($gettopic) or die("Could not get topic");

$gettopic3=mysql_fetch_array($gettopic2);

$postcount="SELECT postcount from Users where Username=$gettopic[author]";

print "<tr class='mainrow'><td valign='top'><p><A href='member_profile.php?username=$gettopic3[author]'>$gettopic3[author]</a></p><p>Posts: $postcount[postcount]</p></td><td vakign='top'>Last replied to at $gettopic3[showtime]<br><hr>";

 

Anyone know how i can do this?

Yes the database's are all included above.

It all works, except instead of displaying the post count it shows an "S". So there is no error that displays, it just shows an s instead of post count.

 

I know that the posts work because i have them displayed in the users profile, but that was easy as all i needed to do was fetch the user name from the URL of the users profile.

ok i think i see problem now. dont you need to have it run the query for $postcount so

$gettopic="SELECT * from post_reply where postid='$id'";

$gettopic2=mysql_query($gettopic) or die("Could not get topic");

$gettopic3=mysql_fetch_array($gettopic2);

$postcount="SELECT postcount from Users where Username=$gettopic[author]";

$postcount2=mysql_query($postcount) or die("Could not get postcount");

$postcount3=mysql_fetch_array($gettopic2);

print "<tr class='mainrow'><td valign='top'><p><A href='member_profile.php?username=$gettopic3[author]'>$gettopic3[author]</a></p><p>Posts: $postcount3[postcount]</p></td><td vakign='top'>Last replied to at $gettopic3[showtime]<br><hr>";

try having it run that

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.