This question already has an answer here:
When i enter a user id that is in the database, i want it to echo/print all the data from that one users file. So if i enter "user_id = 2", i want the users "name", "age" etc etc. I got to where that it gives me everything without the parameters. The code:
$link = mysqli_connect("localhost", "root", "");
mysqli_select_db($link, "magicsever");
if(mysqli_connect_error()){
die ("Database connection error");
}
$query = "SELECT * FROM classified_videos";
$result = mysqli_query($link, $query);
while($row = mysqli_fetch_array($result)){
print_r ($row);
}
But i want from a specific user and this is what i think is the code
if(isset($_POST['submit'])){
$link = mysqli_connect("localhost", "root", "");
mysqli_select_db($link, "magicsever");
if(mysqli_connect_error()){
die ("Database connection error");
}
$query = "SELECT * FROM classified_videos WHERE user_id ='".mysqli_real_escape_string($link, $_POST['userid'])."' LIMIT 1";
$result = mysqli_query($link, $query);
while($row = mysqli_fetch_array($result)){
print_r ($row['vid_category_1']);
}
}
?>
<form method="post">
<input type="text" name="userid" placeholder="user id...">
<input type="submit" value="submit">
</form>
</div>
This if(isset($_POST['submit']))
expects that an input with name submit
is submitted, but youre currently sending only userid
add this name="submit"
to your button:
<input type="submit" value="submit" name="submit">