Jump to content

Help with PHP and MySQL query


lbh2011

Recommended Posts

You need to change this to a while loop

($row = mysql_fetch_assoc($result)) ;{

 

 

It was in your original code, so I don't know at what point you changed it. (Also, remove the semicolon)

while ($row = mysql_fetch_assoc($result)) {

 

Lastly, I inadvertently left off the column names in the dynamic query, which flolam corrected. But, you can make this line

$where_parts[] = str_replace("search", "user", $name)." = '".mysql_real_escape_string(trim($_POST[$name]))."'";

 

much simpler by naming your input fields the same as your db fields. Doing that makes it much easier on you in the future when you have to make changes to your code. That line would look something like this

$where_parts[] = "{$name} = '".mysql_real_escape_string(trim($_POST[$name]))."'";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.