Jump to content

Problem listing entries


MattC

Recommended Posts

I'm trying to write a script that shows movies a user has entered to a site.  If they don't have any movies, a message comes up saying they haven't submitted anything yet.  Here is the code I am trying to use:

 

	
        $base_dir = "../";
include ($base_dir . "elements/db-connect.php");
//Grab the variables
$user_id = $HTTP_GET_VARS["u"];

// simple query to get total no of entries
$countq = mysql_query("SELECT count( * )
FROM sc_topics
WHERE (
topic_poster = '$user_id'
)"); 

    $total = mysql_result($countq, 0, 0); 

if ($total == 0)
{
	echo "No entries yet.";
} elseif ($total > 0) {

		//Get top 5 Showcase entries
		$sql3a ="SELECT t.topic_id, t.topic_title, r.Rating
		FROM sc_topics t, sc_ratings r
		WHERE topic_poster = '$user_id'
		AND t.topic_id = r.Item
		ORDER BY r.Rating DESC LIMIT 5";

		$result3a = mysql_query($sql3a); while ($row = mysql_fetch_array($result3a));

		 {
			$movie_title = $row['topic_title'];
			$movie_id = $row['topic_id'];

				echo "
				<span class=gensmall>
					<a href=\"http://showcase.sfdt.com/viewmovie.php?t=$movie_id\">$movie_title</a>
				</span>
				<br>
				";
			} 

		}

 

The problem is that it will show the text if they have no entries, but nothing shows up if they have the entries.  It runs that part of the loop, but none of the variables come through.  I've tried a lot of different ways of coding this, what am I missing?

Link to comment
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.