简体   繁体   English

单击一个链接以运行MySQL查询以获取链接中的特定值(php)

[英]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. 我所拥有的是HTML表中的数据库表名称列表。 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. 我需要它们为超链接格式,一旦单击表名,它应将表名发送到php文件,然后运行mysql查询以获取表的所有属性。

What's the best way to do this? 最好的方法是什么? thanks for all suggestions in advance. 感谢您提前提出的所有建议。

huh? 嗯? how about phpmyadmin if you want to use querying 如果要使用查询,phpmyadmin怎么样

but if you like to build your own SQL query tool then learn this things: 但是,如果您想构建自己的SQL查询工具,请学习以下内容:

List database: 列出数据库:

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

List Tables: 列表表:

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

and lastly List Fields 最后列出字段

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


ADDING THE AMBIGUOUS REQUEST OF Q-Starter. 添加对Q-Starter的模糊请求。

@example:index.php @example:index.php

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

@example:query.php @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" . 这是不好的编程代码,但是如果您真的想探索然后再尝试使用这些代码,请自行使用,如果其他用户尝试使用所谓的“ SQL INJECTION” ,则可能会损坏您的数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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