Jump to content

mysql_fetch_assoc()


Recommended Posts

I created a db and added content to it. Now I want to get it out. I created a recordset for a simple search for houses buy state.
It works fine in the test, but when I add the dynamic table I get this on the page

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\offers4house\results.php on line 12

I have followed every help page and still cant figure it out. Line 12 is the next to last line of this code for the dynamic table

<table border="1" cellpadding="1" cellspacing="1">
<tr>
<td>state</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['state']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>

I can include the rest of the dreamweaver php for the recordset and query if needed.
Please Please Please! Help
beav33
Link to comment
Share on other sites

Thank you I worked it out, but when I run a search with 2 or more varibles is there some way to run a wildcat. Meaning if someone doesnt type in a varible in say "city" for the search, then my search doesnt work. I figured out the "=" for exact and "LIKE" for something close. If its blank the search shows nothing, even if there is something for the other varible, for instance "state". Can you do something with "OR" to solve this problem or do I have to make multiple search forms to get around this.
Hope this makes sense
Thank you
beav33

$query_Recordset1 = sprintf("SELECT propertytype, squarefootage, askingprice, `city`, `state`, zip FROM houselisting WHERE
`state` = %s AND `city` LIKE CONCAT('%%', %s, '%%')"
Link to comment
Share on other sites

Try new example for some help
I have a search page for houses
Using
city, state OR zip
Also property type and price range.
Now if somebody leaves property type OPTION open
And price range OPTION open
how do I run a wildcat search with the city, state OR zip selected, and these open, for that location
With the city, state I using a query of = for state and LIKE for city.
For the zip I use the =
When I ad OR for property type it works but for all locations, not the state or zip selected.
ex:
Select *
FROM houselisting
WHERE (`state` = colstate OR `city` LIKE %colcity%) OR `zip` = colzip OR `propertytype` = colproperty
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.