SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot darkwarrior's Avatar
    Join Date
    Dec 2010
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Small Query confusion

    Having a small problem with my query below. I'm sure I've done something like this before so am not sure what is causing a problem.

    Basically I want the meta_ids from the column meta_id where post_id = $currentPost.

    Code SQL:
    SELECT meta_id FROM posts_meta WHERE post_id = $post_ID

    But for some reason, even if I remove teh WHERE qualifier, it will only return the earliest meta_id rather than the three test entries I have in place. I var_dump'd the array returning the results and the rows aren't present so while I'm not sure I do think this is an issue with my query and not the PHP side.

    Am I missing something obvious here?

    For context, this is the code I'm using around the query.

    Code PHP:
    $result = mysql_query("SELECT meta_id FROM posts_meta WHERE post_id = $post_ID");
    				$row = mysql_fetch_array($result);
    				$post_meta_ids = $row;
     
     
    		var_dump($row);
    		echo "<br/>";		
    		var_dump($post_meta_ids);

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,019
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    You need to use a loop to fetch all the rows of a result set
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Zealot darkwarrior's Avatar
    Join Date
    Dec 2010
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm...I would've thought $row would contain all the results before I would then just extract them.

    This solved the problem anyway, thanks SpacePhoenix.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •