简体   繁体   中英

Click a link to run MySQL query for that specific value in the link (php)

I had a hard time to find a solution for this, most of the questions asked were to click a button to run a query.

What I have is a list of db table names in a HTML table. I need them to be in hyperlink format, once I click a table name it should send the name of the table to a php file and run mysql query to get all the attributes of the table.

What's the best way to do this? thanks for all suggestions in advance.

huh? how about phpmyadmin if you want to use querying

but if you like to build your own SQL query tool then learn this things:

List database:

http://php.net/manual/en/function.mysql-list-dbs.php

List Tables:

http://www.php.net/manual/en/function.mysql-list-tables.php

and lastly List Fields

http://www.php.net/manual/en/function.mysql-list-fields.php


ADDING THE AMBIGUOUS REQUEST OF Q-Starter.

@example:index.php

<form method="get" action="query.php">
    <label>Statement: </label><input type="text" name="sqlState"/>
</form>

@example:query.php

<?php
    $sqlState = $_GET['sqlState'];
    $result = mysql_query($sqlState);
    echo $result;
?>

This is bad programming codes but if you really want to explore then go and try this codes, just use this on your own, this might damaged your DATABASE if other users tries to use the so called "SQL INJECTION" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM