Jump to content

form sql based on input content


doddsey_65

Recommended Posts

im wanting to change the sql in my query based on if a field is empty or not. if the field is empty then i dont want it to post anything, but if its not empty then it can post the content. heres what i have so far but it does post the content even if the field is empty.

 

(!empty($password)) ? $pass_sql = "u_password = '$password'," : $pass_sql = null;

$link->query("UPDATE ".TBL_PREFIX."users
                SET 
                $pass_sql
u_allow_user_pm = '".$_POST['allow_user_pm']."'
                WHERE u_username = '".$_POST['user_name']."'")
                or die(print_link_error());

 

how can i stop it from updating if the field is empty?

Link to comment
https://forums.phpfreaks.com/topic/228375-form-sql-based-on-input-content/
Share on other sites

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.