sanchit gupta
asked on
Error in php select pdo
<?php
include ("./inc/header.inc.php");
$userid="";
$dblinks = DB::query('SELECT url, title FROM links WHERE user_id!=:userid ORDER BY id DESC', array(':userid'=>$userid));
$links = "";
$links_t = "";
foreach ($dblinks as $u) {
$links .= $u['url'];
//$links .= $
}
foreach ($dblinks as $t) {
$links_t .= $t['title']."<hr /></br />";
}
?>
<div class="links">
<?php echo $links;
echo $links_t;
?>
</div>
The output is coming as all the urls one by one and the title one by one. I want url and title to be together then a <hr> then next url and title and so on. any help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Some good "getting started" examples for PHP and MySQL when using PDO are available in this article
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
ASKER
i also want to make a link to the url both from title and url itself
i also want to make a link to the url both from title and url itself
Can you post a sample output you are looking for?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
stale question
Open in new window
If you can what is the html output you are trying to achieve, it will be better to understand and construct that.