Re: Query Analyzer For MySQL with PHP?
| From: | Plutarck | Date: | Mon, 23 Apr 2001 19:06:15 +0000 |
| Subject: | Re: Query Analyzer For MySQL with PHP? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49907@lists.php.net to get a copy of this message | ||
If you want to input SQL querries through a text box, you can just build an
easy one in PHP. Note: it's extremely unsecure to use for anything more than
personal use.
Just create an HTML form with a textarea and a submit button. Set the action
to the php page and on the PHP page do something like this (we'll say the
textarea name is "query"):
if ($query)
{
$result = mysql_query($query);
}
if (!$result)
{
echo mysql_error();
} else
{
for ($res_num = 1; $row = mysql_fetch_assoc($result); $res_num++)
{
echo "Result number $rew_num: ";
print_r($row);
}
}
Sure it ain't pretty and you should change the print_r() call to a more
controllable function, but it works just fine. You'll of course have to
connect to the database and all before doing this, and change the database
functions to fit your chosen database, but you get the idea.
phpMyAdmin has a more fully featured type deal though, and the above works
only for SELECT statements in MySQL.
--
Plutarck
Should be working on something...
...but forgot what it was.
"Brandon Orther" <orther@webintellects.com> wrote in message
news:OMEBIHJGKOODOFLBFDJFEEGECDAA.orther@webintellects.com...
> Hello,
> I recently took an ANSI SQL class to better familiarize my self with SQL
in
> general. In the class we used MSSQL SERVER 7 and to do queries we used
the
> Query Analyzer. Does anyone know of a PHP script that works like the
Query
> Analyzer so I can test Queries in a Browser? Like A Text Area where I can
> put the query and a simple form that sends it to MySQL.
>
> Thanks,
> Brandon
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>