Afshin Haghighatnia

entry_category_id includes NULL results instead of integer

Vote 0 Votes

Hi.
I'm trying to use a mysql query for showing some entries related to a category. First, I've sent the category_id using a form and get method in a file named compare.php !!!
In a new file named step2.php, I wanted to show the names of all the entries related to chosen category.
So, the code I have used, is this :

$category = (int)$_GET['category_id'];

$query = mysql_query ("SELECT * FROM mt_entry where `entry_category_id`=$category")or die(mysql_error());

Unfortunately, there is no Category ID in entry_category_id and all of results are NULL !
Can somebody help me to write this query ?! I would really appreciate it.

Reported on Movable Type 5

1 Reply

| Add a Reply
  • Replace your query with the following:

    $query = mysql_query ("SELECT * FROM mt_entry, mt_placement, mt_entry WHERE (placement_category_id = category_id) AND (placement_entry_id = entry_id) AND (category_blog_id = $category) AND (entry_status = 2) ORDER BY entry_created_on DESC LIMIT 5")or die(mysql_error());

    This query would list for you the latest 5 entries that are published (not also the draft posts, or the ones scheduled to be published later).

    You could change the ordering criteria or the number of posts displayed, playing with:

    ORDER BY entry_created_on DESC LIMIT 5

    Kind Regards,
    Mihai Bocsaru

    ----------------------------------
    Daily Movable Type Consultant

    Web Development
    Movable Type Consulting
    Six Apart Partner

    http://www.pro-it-service.com/
    ----------------------------------

    Movable Type Demo
    http://www.movabletypedemo.org/
    ----------------------------------

    Open Melody Demo
    http://www.openmelodydemo.org/

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

code.sixapart.com

137 479

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

238 797

Last Topic: Manifest Schema Compatibility Issue When Restoring Blog by Matt on Oct 17, 2012

1858 6594

Last Topic: Categories and Basename Publishing Issues by e21media on Oct 25, 2012

88 307

Last Topic: absolute publish date in Manage Entries screen by .mau. on Apr 18, 2012

1488 5347

Last Topic: Anti-cloning by .mau. on Oct 29, 2012

732 3093

Last Topic: Blog moved server - now users cannot access blog? by mowgs on Oct 30, 2012

89 317

Last Topic: How to "pretify" a url in htaccess with a few wildcards by Caio on May 30, 2012

183 771

Last Topic: Commenting with TypePad by Rob Ferrara on Oct 17, 2012

212 680

Last Topic: Does MT-Approval work in MT5? by DLpres on Sep 25, 2012

27 100

Last Topic: Upgrading MT by Caio on Oct 15, 2012

49 224

Last Topic: Movable Type 6 Ideas by Caio on May 28, 2012

65 248

Last Topic: Expanding new rich text editor and implementing table function by Takeshi Nick Osanai on Jul 30, 2012