Jump to content

Please help with insert data


bashaclick

Recommended Posts

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 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/284589-please-help-with-insert-data/
Share on other sites

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.

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.