Skip to content

Instantly share code, notes, and snippets.

@ryansukale
Last active January 4, 2016 20:09
Show Gist options
  • Select an option

  • Save ryansukale/8672086 to your computer and use it in GitHub Desktop.

Select an option

Save ryansukale/8672086 to your computer and use it in GitHub Desktop.
A sample mysqli insert-update statement for strings, numbers and dates.
$now = date("Y-m-d H:i:s");
//Insert
$query = 'insert into '.$tableNamespace.'tableName(field1, field2, field3, field4) values ('.
'"'.$strValue1.'",'.
'"'.$strValue2.'",'.
$intValue3.','.
'"'.$now.'"'.
')';
mysqli_query($con,$query);
//Update
$query = 'update '.$tableNamespace.'tableName set numeric_field = 1, date_field="'.$now.'" where numeric_condition='.$numeric.' string_condition ="'.$string.'"';
mysqli_query($con,$query);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment