Reputation: 1
I am kind of stuck since I never tried to get something from the database in this way.
My problem:
I have a single line of code that goes to a website for example src = "www.youtube.com"
however that link is stored in a database that has 1 single table called link so i retrieve this link like this
$sql = $db->prepare("SELECT link FROM youtubevid");
I have always used id's but for this table there is no need because it will get updated and i only need that 1 link. My question is how do i echo this?
Help is much appreciated
Thanks!
Upvotes: 0
Views: 278
Reputation: 12440
I guess you are using PDO
to do that, if that's the case then you need to execute the query and fetch the result, after the line that you have specified i.e after the.
$sql = $db->prepare("SELECT link FROM youtubevid");
Here is the complete code:
// prepare the query
$sql = $db->prepare("SELECT link FROM youtubevid");
// execute it
$sql->execute();
// fetch the result
$result = $sql->fetch();
// echo out the column.
echo $result['link'];
Upvotes: 2