I am trying to implode an array into a sql statement. My question is, how is the best way for the values to have quotations around strings, and dates, etc, but not around int values?
-edit- New code below, The issue i was hainv was using backticks instead of quotes on values, thanks Mark Baker, As far as prepared statements to stop sql injection, will the below code suffice? the column names are set by the code, and all vaules are myslqi_real_escape'ed.
$HardwareDistribution["HardwareID"]=mysqli_real_escape_string($con,$_POST["HardwareID"]);
$HardwareDistribution["UserID"]=mysqli_real_escape_string($con,$_POST["UserID"]);
$HardwareDistribution["DateGiven"]=mysqli_real_escape_string($con,$_POST["DateGiven"]);
$HardwareDistribution["ConditionGiven"]=mysqli_real_escape_string($con,$_POST["ConditionGiven"]);
$SQL_AssignHardware="INSERT INTO HardwareDistribution (`".implode("`,`",array_keys($HardwareDistribution))."`) VALUES ('".implode("','",array_values($HardwareDistribution))."')";
mysqli_query($con,$SQL_AssignHardware);