russianbear Posted August 22, 2009 Share Posted August 22, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/171433-bind_result-fetch-issues-mysqli-help-puh-puh-puh-please/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.