I have a table in MySQL named \"updates\" that currently holds the following information:
What I need is the
Assuming you are using mysqli (and not PDO) you can't use a simple query() because you want to execute multiple commands. You will need to use multi_query() in combination with store_result(), more_results() and next_result().
Here is some code I used once:
$db=mysqli_connect($databasehost,$databaseuser,$databasepass,$databasename) or die ("Connection failed!");
$result = $db->multi_query($sql);
if ($err=mysqli_error($db)) { echo $err."
"; }
if ($result) {
do {
if ($res = $db->store_result()) {
echo "";
// printing table headers
for($i=0; $i{$field->name}";
}
echo " \n";
// printing table rows
while($row = $res->fetch_row())
{
echo "";
foreach($row as $cell) {
if ($cell === NULL) { $cell = '(null)'; }
echo "$cell ";
}
echo " \n";
}
$res->free();
echo "
";
}
} while ($db->more_results() && $db->next_result());
}
$db->close();