I have a little SQL Commands Here
Databasename:Numbers
select * from tblstart where id = 1
output = 10
select * from tblstart where id = 2
output = 20
select * from tblstart where id = 3
output = 30
select * from tblstart where id = 4
output = 40
select * from tblstart where id = 5
output = 50
How can i transfer this output in textbox during Page Load
<input type="text" name="OutputOf10"><br>
<input type="text" name="OutputOf20"><br>
<input type="text" name="OutputOf30"><br>
<input type="text" name="OutputOf40"><br>
<input type="text" name="OutputOf50"><br>
Any help would be appreciated TY
Here is the code so far but im getting errors
Here is the php code(Updated)
<?php
$host = 'localhost';
$db_user = 'root';
$db_pass = '';
$db_name = 'poi';
try {
$pdo = new PDO('mysql:host='.$host.';dbname='.$db_name.'', $db_user, $db_pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare('SELECT COUNT(name) FROM tblmarker WHERE name = (Robbery)');
$stmt->execute(array('id'));
$result = $stmt->fetchAll();
if ( count($result) ) {
foreach($result as $row) {
$OutputOf10 = $row['Name'];
echo '<input type="text" name="OutputOf10" value="'.$OutputOf10.'"><br>';
}
} else {
echo "No rows returned.";
}
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
?>
You are missing quite a bit of information that would allow us to better help you.
Here's a start:
<?php
$host = 'localhost';
$db_user = 'root';
$db_pass = '';
$db_name = 'poi';
try {
$pdo = new PDO('mysql:host='.$host.';dbname='.$db_name.'', $db_user, $db_pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare('SELECT name from tblmarker where id = 112"');
$stmt->execute(array('OutputOf10' => $id));
$result = $stmt->fetchAll();
if ( count($result) ) {
foreach($result as $row) {
$OutputOf10 = $row['name'];
echo "<input type="text" name="OutputOf10" id="OutputOf10" value='".$OutputOf10."' ";
}
} else {
echo "No rows returned.";
}
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
?>
<input type="text" name="OutputOf10" value="<?php echo $Outputof10 ?>"><br>
To support update:
<?php
$id = 112;
$host = 'localhost';
$db_user = 'root';
$db_pass = '';
$db_name = 'poi';
try {
$pdo = new PDO('mysql:host='.$host.';dbname='.$db_name.'', $db_user, $db_pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare('SELECT * FROM tblmarker WHERE id = :id');
$stmt->execute(array('id' => $id));
$result = $stmt->fetchAll();
if ( count($result) ) {
foreach($result as $row) {
$OutputOf10 = $row['name'];
echo '<input type="text" name="OutputOf10" value="'.$OutputOf10.'"><br>';
}
} else {
echo "No rows returned.";
}
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
?>