Jump to content

Bind_result & fetch issues (mysqli) - Help puh puh puh PLEASE!!!!


russianbear

Recommended Posts

I am building a mini version of the Craigslist.

Here is the gist...After a user's post info is validated, I write it to the db...Check.  Now, if the same user wants to view other posts, I have a page where they can narrow their seach parameters.  So, after they submit these parameters I use them in a  prepared statement to return a list of post titles (which I am going to make hyperlinks to the actual posts).  One step at a time though...for some reason my code is not working properly in returning the post titles.  I currently have only 3 locations to choose from (for simplicity reasons - I'll add more later), but my code returns the results for ONLY the first location that I have in my pull down menu that narrows down the search parameters, none else.

 

if($Title_Query = $conn->prepare("SELECT Title FROM POSTS as p,

                                    LOCATION as l, SUBCATEGORY as s, REGION as r, CATEGORY as c

                                    WHERE((p.Location_ID=?) AND (p.SubCategory_ID=?) AND               

                                    (r.Region_ID=?)

                                    AND (p.SubCategory_ID = s.SubCategory_ID)

                                    AND (p.Location_ID = l.Location_ID)

                                    AND (s.Category_ID = c.Category_ID)

                                    AND (l.Region_ID = r.Region_ID))")) { 

     

   

      $Title_Query->bind_param('iii', $field1, $field2, $field3);

 

      $field1 = $Sub_Category_ID;     

      $field2 = $Location_ID;

      $field3 = $Region_ID;

 

      $Title_Query->execute();

 

      $Title_Query->bind_result(&$Post_Title);

   

      //Okay, got the result, now output them to the screen

      echo "<h3>$Region_Name -> $inputArray[location] -> $Category_Name -> $inputArray[sub_category]</h3>";

      echo "The following records were found:";

      echo "<br><br>";

 

    while($Title_Query->fetch()) {

        echo "<a href = \"localhost/build_listing.php\"><u>$Post_Title</u></a>";

        echo "<br>";

      }//end while

 

      $Title_Query->close();   

  }//end if

 

I don't understand why it would work for some of the parameters, not all...

Is my problem obvious or is the problem elsewhere in my code?  I'm 99.999% my bind_result and fetch logic is the problem, but I can't see it!    :shrug:

 

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.