I want to create a main page for my learning site (trying to learn stuff), but I have a problem with (I think) getting response from query.
HTML for getting the table what I want. Value in button is the table name from Database
<body>
<div class="s">
<form action="table.php" method="POST">
<ul>
<!-- <li><input class="button" type="submit" name="ok" value="**table name**"></li> -->
<li><input class="button" type="submit" name="ok" value="name"></li>
<li><input class="button" type="submit" name="ok" value="exam"></li>
</ul>
</form>
</div>
</body>
PhP
if (isset($_POST["ok"]))
{
$TableIWant = $_POST["ok"]; //Stores the name of the table
$servername = "X";
$username = "X";
$password = "X";
$dbname = "X";
//Sql - gets column names?
$sqlcol = "SELECT CONCAT('',GROUP_CONCAT(`COLUMN_NAME`),'') FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`='$dbname' AND `TABLE_NAME`= '$TableIWant'";
//create connection
$conn = new mysqli($servername, $username, $password, $dbname);
echo "$sqlcol <br>"; // writes out (just for chechk)
$column = $conn->query($sqlcol);
echo "$column <br>";
// after I get column names I go and get the data from database and make table, but I am stuck on getting the column names
}
New contributor
jik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.