Jump to content

Is This a Proper Use of fetch_all () or Is There an Alternative?


Glese

Recommended Posts

if (isset($select_category) || isset($most_liked)) {
// ALL but NO OTHER
if (((($select_category == 'All') || (!isset($select_category)))) && (!isset($most_liked))) {

           
	$query	= "SELECT * FROM con, user WHERE con.user_id = user.user_id ORDER BY contribution_date DESC";

	fetch_all ($dbc, $query);


// CATEGORY but NOT most_liked	
} elseif (isset($select_category) && !isset($most_liked)) {

	$query = "SELECT * FROM con, user WHERE con.user_id = user.user_id AND category = '$select_category' ORDER BY contribution_date DESC";

	fetch_all ($dbc, $query);

// CATEGORY and MOST_LIKED
} elseif (($select_category != 'All') && (isset($select_category) && isset($most_liked))) {

	$query = "SELECT * FROM con, user WHERE con.user_id = user.user_id AND category = '$select_category' ORDER BY likes DESC";

	fetch_all ($dbc, $query); 

// ALL or NO CATEGORY but MOST LIKED 
} elseif ((($select_category == 'All') || (!isset($select_category))) && (isset($most_liked))) {

	$query = "SELECT * FROM con, user WHERE con.user_id = user.user_id ORDER BY likes DESC";
	fetch_all ($dbc, $query); 

} 

}

 

What I am basically trying to accomplish is, choose a category through a drop down list, select that category and then go through all the rows in the database and print the content out.

 

As of now it is working for me, I am also using a pagination script to print out everything in a table.

 

The problem I am having is that fetch_all function is also printing the query out together with the content. Any ideas why it does that?

 

Did I use this function the right way?

 

If you need more information let me know.

 

 

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.