A batch file is a specific file with series of sql queries.You can copy files of this sort by loading them and clicking on Execute button, or by writing them down in the Query text field and clicking again on button Execute. If last query in your script return the result you can see it in same window.
//---------------------------------------------------
function connect_to_db(){
global $mydatabase, $mydb, $myusername, $mypassword;
$db = mysql_connect($mydb, $myusername, $mypassword);
if (!$db) die("A database selection error has occurred!");
mysql_select_db($mydatabase,$db);
return ($db);
}
//------------------------------------------------------
function batch_query($dquery){
if ($dquery=='') {echo 'The query was empty'; exit;}
$queryes = explode(';',$dquery);
$db=connect_to_db();
foreach ($queryes as $query){
$query=trim($query);
if ($query<>'') {
$result = mysql_query($query.';',$db) or die (mysql_error($db));
}
}
return ($result);
}
//------------------------------------------------------
function show_result($result){
if ($result && mysql_num_rows($result) > 0) {
echo "<table width=\"100%\" border=\"1\" align=\"center\" cellpadding=\"1\" cellspacing=\"0\">\n";
echo '<tr>';
while ($i < mysql_num_fields($result)) {
$meta = mysql_fetch_field($result, $i);
echo '<td>';
echo $meta->name;
echo '</td>';
$i++;
}
echo '</tr>';
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
mysql_free_result($result);
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><title>MyQuery php</title></head>
<body bgcolor="#E2E2E2" text="#666666" link="#666666" vlink="#666666" alink="#666666">
<form name="form1" method="POST" action="">
<table border="0" align="center" cellpadding="8" cellspacing="0">
<tr>
<td align="center" valign="top"><a href="http://www.delphipages.com/result.cfm?SR=oleg%5Fpetkov&AO=and&RequestTimeout=500#root#/index.cfm">
You can download "MyQuery" free windows application from here!</a></td>
</tr>
<tr>
<td align="center" valign="top">
<textarea name="myquery" cols="80" rows="15" id="myquery">
<?php
//It is only for a test! You can clear php code from here ....
if (!isset($_POST['myquery'])||!(isset($_POST['Clear'])&&$_POST['Clear']=='Clear')) print_r("
DROP TABLE IF EXISTS test.abon_plan;
CREATE TABLE IF NOT EXISTS test.abon_plan
(
id INTEGER NOT NULL auto_increment PRIMARY KEY,
abon_plan varchar(40),
abon_plan_cyr varchar(60),
comment varchar(100),
code char(3) NOT NULL DEFAULT 'IKO',
deleted enum('N','Y') NOT NULL
);