sanchit gupta
asked on
Errors in links opening
I have made a code which selects url and title from links table in database. I want links to the respective urls. For eg: if url on the page says "www.google.com" upon clicking on it it should redirect to google.com. The below code displays an error of headers already sent.
<?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'].'<br>'.$u['title'].'<hr>' ;
}
?>
<div class="links">
<?php
header('Location: echo $links;'); ?>
</div>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That removed that error but still desired output is not achieved
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@gr8gonzo it worked thanks!
Could you please help me with styling too. As in I want to style both url and title differently.
Could you please help me with styling too. As in I want to style both url and title differently.
ASKER
@gr8gonzo Could you please help me with styling too. As in I want to style both URL and title differently.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I just want to modify font size for both.
Okay. CSS is the correct way to do that.
ASKER
how to apply css in this case when you have same class for both variables?
If you need to distinguish between two HTML elements, there are several ways to do that, but the simplest way is probably to wrap the title in a <span> tag with a named class attribute.
Add ob_start() after line 1:
Open in new window