I have wrote a function for checking wether a record exists in a table, to save writing this every 5 minutes in my code. I also want to write functions for inserting and deleting items from a table, and it may be because its 8am on a sunday, or maybe i just really can't do it.
Anyway, i was going on the lines of:
function insert_record($arrayofcolumnnames, $arrayofvalues, $table, $mysqli){
$stmt = $db->prep_stmt(" {Statement Here} ");
$stmt->execute( ) or die ("Could not execute statement");
$stmt->close();
}
This is where i'm at a loss, How would i go about transferring the array of column names and values to the prepared statement, is there a way to count the array fields and insert the ?'s based on this? If so, how please
$arrayofcolumnnames[i] = ?
Or am i completely at a loss here?

New Topic/Question
Reply




MultiQuote



|