Hi there, I am trying to use data entered into a form as part of my PHP/MySql script.
I just can’t seem to get the $row[‘$column’] to work. Below is what I have so far. I am trying to use the data entered into the Column form as a reference for returning the column in the database.
<html><head></head><body>
<form action="return.php" method="post">
Table:</br><input type="text" size="20" name="table"></br>
Column:</br><input type="text" size="20" name="column"></br>
<input type="submit" value=" Get ">
</form>
<?php
require_once(connection.php);
mysql_select_db($database_connect);
if (isset($_POST['table'])) {
$table = $_POST['table'];
$column = $_POST['column'];
$query = "select * from $table";
$result = mysql_query($query);
if ($result) {
while ($row = mysql_fetch_array($result)) {
//Here's where I want to use the form data:
echo $row['$column']."</br>";
}
mysql_free_result($result);
} else {
echo mysql_error();
}
mysql_close();
//If not set
} else {
echo "No Table Selected";
}
?>
</body></html>
Any ideas how I can do this?
Thanks!
Peter.