Ok, not so good in PHP, i have a database (mysql), and a form with many field submitting to the database, i need to call all the values and display them into the text box's accordingly so they can be edited and submitted again. please help
I'll give a very simple example that should get you started.
The values are accessible via (most likely) $_POST['input_name']
. Without using Post/Redirect/Get, you can just get the input values like:
$input_name = isset($_POST['input_name']) ? $_POST['input_name'] : '';
Then later you'll display it in the form like:
echo '<input name="input_name" value="'
. htmlspecialchars($input_name, ENT_QUOTES) . '">';
If you want to use P/R/G, which you should do, you need to store the input in the $_SESSION
.
session_start();
//initialize all inputs to the empty string
if (!isset($_SESSION['inputs'])) {
$_SESSION['inputs'] = array('input_name' => '');
}
if ('POST' == $_SERVER['REQUEST_METHOD']) {
$_SESSION['inputs']['input_name'] = isset($_POST['input_name']) /* etc. */;
}
You can then output it in your form via $_SESSION
instead of $_POST
.
You can do this with php and HTML:
<?php
$con = new mysqli(host,user,pass,db_name);
$query = "SELECT * FROM table";
$result = $con-> query($query);
while ($row = $result->fetch_assoc()){
$value = $row['column'];
echo "<input type ='text' value ='".$value."'>";
}
?>