I have a database setup something like this
someid | age | title | zipcode
2101 35 Agent 12345
3507 46 Broker 23456
7889 21 Intern 34567
What I am trying to do is get the information from a specific row, if the input from a webpage matched the ID of one in the database. Fromthe table above if I search for ID 3507, then I want to see all of the info on that row: ID: 3507, Age: 46, Title: Broker, Zipcode 23456.
I can get the info for the entire database (“SELECT * FROM mydatabase”) but can someone point me in the direction of being able to compare the form input to the first column ID and if it matches echo the complete row?
A copy of what I have coded is below.
Thanks for any help in advance.
(Yep, I’m a noob at MySql)
Jim
<?php$servername = "localhost";
$username = "myusername";
$password = "mypassword";
$dbname = "mydatabase";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$findthis = mysqli_real_escape_string($conn, $_REQUEST['key']);
$sql = "SELECT someid FROM mydatabase";
if ($sql = $findthis)
{
$sqla = "SELECT someid, age, title, zipcode FROM mydatabase WHERE someid = $findthis"; echo "ID: " . $row["someid"]. "\nAge: " . $row["age"]. "\nTitle: " . $row["title"]. "\nZip: " . $row["zipcode"]. "\n\n";
}
else
{
echo "0 results";
}
$conn->close();
?>