bashaclick Posted December 6, 2013 Share Posted December 6, 2013 Hello, I want your help I have this code case "addads": // $qry = "INSERT INTO 4sale_categories SET catImage1 = '".mysql_real_escape_string(trim($_GET['catImage1']))."' , catImage2 = '".mysql_real_escape_string(trim($_GET['catImage2']))."' , catImage3 = '".mysql_real_escape_string(trim($_GET['catImage3']))."', catImage4 = '".mysql_real_escape_string(trim($_GET['catImage4']))."', catImage5 = '".mysql_real_escape_string(trim($_GET['catImage5']))."', admin_id = '0', phone = '".mysql_real_escape_string(trim($_GET['phone']))."', email = '".mysql_real_escape_string(trim($_GET['email']))."', subcategory = '".mysql_real_escape_string(trim($_GET['subcategoryid']))."', categoryName = '".mysql_real_escape_string(trim($_GET['categoryid']))."', description = '".mysql_real_escape_string(trim($_GET['description']))."', device_token = '".mysql_real_escape_string(trim($_GET['device_token']))."', created = NOW()"; $sql = mysql_query($qry); I want to make condition if catImage1 is null insert default value in catimage1 or keep same data Thank you Quote Link to comment https://forums.phpfreaks.com/topic/284589-please-help-with-insert-data/ Share on other sites More sharing options...
Barand Posted December 6, 2013 Share Posted December 6, 2013 (edited) Define your table column to have default value. If the image value is null, exclude that column from the insert query. If no value is inserted in the column then the default will be used. edit: BTW that table needs normalizing. Edited December 6, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/284589-please-help-with-insert-data/#findComment-1461525 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.