T
T
torik22rus2019-12-25 08:12:56
PHP
torik22rus, 2019-12-25 08:12:56

How to display a row from the database by the specified parameter?

It is necessary to display a row from the database with a specific id, which must be set on the page in a text field. I know how to display a pre-specified id. Help improve the code.
<?php
$sql = mysqli_query($link, 'SELECT `ID`, `st_form` FROM `q6m0n_qf3_ps` WHERE st_user=103');
while ($result = mysqli_fetch_array($sql)) {
echo "{$result['st_form']}";
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AUser0, 2019-12-25
@torik22rus

If the request is http://site.ru/script.php?user=103, then:

<?php
$sql = mysqli_query($link, 'SELECT `ID`, `st_form` FROM `q6m0n_qf3_ps` WHERE st_user="'.mysqli_real_escape_string($link, $_REQUEST['user']).'"');
while ($result = mysqli_fetch_array($sql)) {
echo "{$result['st_form']}";
}
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question