I have a problem with this page
the green go logo next to the image is meant to visit the promotions site saved on my database. But it loads the same page in a new tab.
My code for this is:
<a href="<?php echo $data['promo_link']; ?>" target="_blank"><img alt="" title="" src="GO.png" height="50" width="50" align="right" /></a>
Any ideas why it does not work?
If you need any code for any of my pages then please let me know and I will edit this and add it.
Thanks.
HOW DO I HREF MY GO IMAGE TO A LINK SAVED UNDER promo_link IN MY DATABASE TABLE?
<?php
include_once('include/connection.php');
include_once('include/article.php');
$article = new article;
**if(isset($_GET['id'])) {
$id = $_GET['id'];
$data = $article->fetch_data($id);**
$articles = $article->fetch_all();
?>
<html>
<head>
<title>xclo mobi</title>
<link rel="stylesheet" href="other.css" />
</head>
<body>
<?php include_once('header.php'); ?>
<div class="container">
<a href="index.php" id="logo">Category = ???</a>
<?php foreach ($articles as $article) {
if ($article['promo_cat'] === $_GET['id']) { ?>
<div class="border">
<a href="single.php?id=<?php echo $article['promo_title']; ?>" style="text-decoration: none">
<img src="<?php echo $article['promo_image']; ?>" border="0" class="img" align="left"><br />
**<a href="<?php echo $data['promo_link']; ?>" target="_blank"><img alt="" title="" src="GO.png" height="50" width="50" align="right" /></a>**
<br /><br /><br /><br />
<font class="title"><em><center><?php echo $article['promo_title']; ?></center></em></font>
<br /><br />
<font class="content"><em><center><?php echo $article['promo_content']; ?></center></em></font>
</div><br/><br />
</a>
<?php } } } ?>
</div>
<?php include_once('footer.php'); ?>
</body>
</html>
Your href
attribute is empty and because you're using target="_blank"
clicking on the link will open the same page in a different tab.
The $data['promo_link']
is empty. I can't tell why because there is no code.
Edit
It seems you forgot the brackets
replace $article = new article;
with $article = new article();
also $article->fetch_data($id)
is probably returning an empty value.
As I can see, your id value is "FREE". make sure that article->fetch_data("FREE")
returns what you expecting it to return.
I also suggest changing you code style. This is much more easy to read:
if ($param){
echo '<div>' . $data["bla"] . '</div>';
}
mixing your PHP code and yout HTML code makes it hard to read and understand.
Note: <font class="title"><em><center><?php echo $article['promo_title']; ?></center></em></font>
is deprecated. Use CSS:
HTML/PHP code:
echo '<div class="title">' . $article['promo_title'] . '</div>';
And the CSS:
.title{
text-align: center;
font-size: 1.5em;
}