I was just wondering if I could do a php code with a database that goes like this: (ID, username, full name, channel, link, email, skype)
. I want the database to have everyones data but in the php code I would like it to only echo the data of the username
. Im not sure if it makes to much sense but for example if my username
is x
and there are 3 different recruiters x
,y
, and z
with a total of 10 data for the database, I only want the data created by x
to show because the username = x
.
Sorry if this doesn't make sense, I don't try to confuse anyone. So if you can't understand feel free to post below and I will happily answer your questions as best as I can. If you can't be bothered no problem. Thanks for the time guys.
Yes, it's simple SELECT
statement:
$db = new PDO(
$config['connectionString'],
$config['username'],
$config['password']
);
$query = $db->prepare('SELECT * FROM `users_table` WHERE `username` = :user');
$query->execute([':user' => "Slayer5000"]);
$user = $query->fetch(PDO::FETCH_OBJ);
UPDATE WITH YOUR CODE
<?php
$db = new PDO(
"mysql:host=127.0.0.1;port=3306;dbname=goaerox_lkdb1",
"goaerox_lkdb1",
"njimkolp"
);
$query = $db->prepare('SELECT `id`, `channel`, `email`, `paypal`, `network`, `name` FROM `partners` WHERE `name` = :user');
$query->execute([':user' => $your_user_name_to_search_for]);
$user = $query->fetch(PDO::FETCH_OBJ);
echo "<table>";
echo "<tr><td>ID</td><td>Username</td><td>Full Name</td><td>Channel</td><td>Link</td><td>Email</td><td>Skype</td></tr>";
echo "<tr>";
echo "<td>{$user->id}</td>";
echo "<td>{$user->name}</td>";
echo "<td>{$user->name} <{$user->}></td>"; // Have no idea how you generate fullName here
echo "<td>{$user->channel}</td>";
echo "<td>{$user->paypal}</td>";
echo "<td>{$user->email}</td>";
echo "</tr>";
echo "</table>";
?>