Database link not working - php

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:
<img alt="" title="" src="GO.png" height="50" width="50" align="right" />
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">
Category = ???
<?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 />
**<img alt="" title="" src="GO.png" height="50" width="50" align="right" />**
<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;
}

Related

Display image to my osclass website

i have this function and it echos a banner of 250*250 banner. Now i want to display a image to this content. I cant figure out how i can display images. Can someone help this is my code
if(!function_exists('aiclassy_draw_ad')) {
function aiclassy_draw_ad(){
echo '<div class="advertise_area">
</div>';
echo ' <br /> <div class="advertise_area">
</div>';
echo ' <br /> <div class="advertise_area">
</div>';
echo ' <br /> <div class="advertise_area">
</div>';
}
}
You might want to use the <img /> HTML element.
In Osclass, you will propbably store your image in your theme (convention is two put images in oc-content/themes/your_theme/assets/img/).
In that case :
<img src="<?php echo osc_current_web_theme_url("assets/img/your-image.jpg"); ?> alt="alt attribute of your image" />

page on selected articles not displaying content

I have my website LOCATED HERE.
If you click on "FREE" on the home page then click one of the logos for the 2 offers to be diverted to the /single.php?id= page, You can see that the logo and text are displayed.
However MY PROBLEM IS: if you click on "GIFT" from the home page you can see the logo and description but then clicking on the logo it brings up the /single.php?id= page once again but it has a problem loading.
my code for single.php is:
<?php
include_once('include/connection.php');
include_once('include/article.php');
$article = new storearticle;
if(isset($_GET['id'])) {
$id = $_GET['id'];
$data = $article->fetch_data($id);
?>
<html>
<head>
<title>Xclo Mobi</title>
<link rel="stylesheet" href="other.css" />
</head>
<body>
<?php include_once('header.php'); ?>
<div class="container">
Title Page<br /><br />
<div align="center">
<img src="<?php echo $data['promo_image']; ?>" class="img"><br />
<font class="title"><?php echo $data['promo_title']; ?></font>
<p>
<?php echo $data['promo_content']; ?>
<img alt="" title="" src="GO.png" height="50" width="50" align="right" />
<br /><br /></div>
<b><u>More From This Brand</b></u>
<br /><br />
← Home
</div>
<?php include_once('footer.php'); ?>
</body>
</html>
<?php
} else {
header('location: index.php');
exit();
}
?>
can someone please tell me where I am going wrong because I have been trying to fix this for days.
If you need any more information from me then please ask. thank you.

Php if empty variable statement

I'm trying to build an if statement for when a variable is filled with a url it will display a button and link to the site, and when the variable is empty the link and button will not display. So far I got it to where it is displays the button and links but making it into an if statement keeps on breaking my site. If you see a problem with the code below, please help. Thanks
<div id="social_icon">
<?php if (isset($fburl))
{
<a href="<?php echo $options['fburl']; ?>">
<img src="http://farm6.staticflickr.com/5534/9135106179_43deba3d15_o.png"" width="30"
height="30"></a>;
}
else
{
//dont show anything
}
?>
</div>
You're trying to use HTML within your PHP code, so PHP sees this as an unexpected variable/string. Either use echo for this, or close the PHP statement, and then write your HTML.
Either:
<div id="social_icon">
<?php if(isset($fburl)){ ?>
<a href="<?php echo $options['fburl']; ?>">
<img src="http://farm6.staticflickr.com/5534/9135106179_43deba3d15_o.png" width="30" height="30" />
</a>
<?php }else{
//dont show anything
} ?>
</div>
Or:
<div id="social_icon">
<?php if (isset($fburl)){
echo '<img src="http://farm6.staticflickr.com/5534/9135106179_43deba3d15_o.png" width="30" height="30" />';
}else{
//dont show anything
} ?>
</div>
Edit
Actually, I would assume it's not outputting anything because your if statement is checking for $fburl whereas you're echoing the link as $options['fburl']. If the facebook url is located at $options['fburl'], try:
<div id="social_icon">
<?php if(isset($options['fburl'])){ ?>
<a href="<?php echo $options['fburl']; ?>">
<img src="http://farm6.staticflickr.com/5534/9135106179_43deba3d15_o.png" width="30" height="30" />
</a>
<?php }else{
//dont show anything
} ?>
</div>
Edit 2
If the options are set but don't contain a link, you will also need check for that:
<div id="social_icon">
<?php if(isset($options['fburl']) && !empty($options['fburl'])){ ?>
<a href="<?php echo $options['fburl']; ?>">
<img src="http://farm6.staticflickr.com/5534/9135106179_43deba3d15_o.png" width="30" height="30" />
</a>
<?php }else{
//dont show anything
} ?>
</div>
Syntax error, change it to:
<?php if (isset($fburl))
{
//missed end tag here
?>
<a href="<?php echo $options['fburl']; ?>">
<img src="http://farm6.staticflickr.com/5534/9135106179_43deba3d15_o.png"" width="30"
height="30"></a>;
<?php
//add another php start tag
}
else
{
//dont show anything
}
?>

correct place for my form tag to pass correct value in action PROBLEM

i have this code:
<body>
<div class="header">
<?php if (isset($_SESSION['user_id']) && !isset($menu)) { ?>
<div class="menu_holder">
<ul>
<li>
<a href="<?php echo ADDRESS; ?>menu.php" class="green_link">
<img src="<?php echo IMAGES; ?>template/menu.gif" width="51" height="20" border="0" />
</a>
</li>
</ul>
</div>
<?php } ?>
<?php
if (!isset($plainHeader))
{
$plainHeader = " ";
?>
<img src="<?php echo IMAGES; ?>template/logo.gif" width="160" height="94" />
<?php
}
?>
</div>
<br/>
<?php $id_to = $user['profile_id_contact']; ?>
<div class="main_content">
<center>
<div class="innerContainer">
<span class="headings2">FREE CHAT CONTACTS</span>
<form id="message_area" style="display:none" method="post" action="<?php echo ADDRESS; ?>messageSent.php?id=<?php echo $id_to ?>">
<?php
if (count($users) > 0)
{
foreach ($users as $user)
{
//some php here
?>
<a href="#" class="charcoal_link" style="line-height: 20px;" onclick="showMessageArea(this); return false;" >
<?php echo $uniqueCode1?><span class="pink_text"><?php echo $uniqueCode2?></span><?php echo $uniqueCode3?>
</a>
<textarea name="message" rows="10" cols="20"></textarea>
<input name="Submit" type="submit" value="Send"></input>
<?php
}
}
?>
</form>
</div>
</center>
</div>
</body>
as my code is now the form tag is in the wrong place because my tag links does not show.
where must i put my form tag so that when i click on any of the uniquecode links i pass the correct $id_to in the action??? when i move the form tag after the my links show but regardless of which link i click on it passes the first link's $id_to with the action. i have also tried to pass $id_to as a hidden field which i had after the sumbit but still it passes the first link's id
please help? i have been struggeling with this for some time now...i cannot redirect the page via JS becuase this site is for a MOBILE aka mobi site
please help? im desperate
thank you
if i move the form tag and have it like this:
messageSent.php?id=">
and i view the page source $id_to contains correct id but as sson as i go to sentMessage.php the id in the url is incorrect
To pass a id to the next page in a link you need to add "?id='.$id.'" at the end of the url.
e.g.
<a href="<?php echo ADDRESS; ?>menu.php?id=5" class="charcoal_link" style="line-height: 20px;">
To make sure that each link is different you can right click and copy the url to double check.

PHP & WP: Render Certain Markup Based on True False Condition

So, I'm working on a site where on the top of certain pages I'd like to display a static graphic and on some pages I would like to display an scrolling banner.
So far I set up the condition as follows:
<?php
$regBanner = true;
$regBannerURL = get_bloginfo('stylesheet_directory'); //grabbing WP site URL
?>
and in my markup:
<div id="banner">
<?php
if ($regBanner) {
echo "<img src='" . $regBannerURL . "/style/images/main_site/home_page/mock_banner.jpg' />";
}
else {
echo 'Slider!';
}
?>
</div><!-- end banner -->
In my else statement, where I'm echoing 'Slider!' I would like to output the markup for my slider:
<div id="slider">
<img src="<?php bloginfo('stylesheet_directory') ?>/style/images/main_site/banners/services_banners/1.jpg" alt="" />
<img src="<?php bloginfo('stylesheet_directory') ?>/style/images/main_site/banners/services_banners/2.jpg" alt="" />
<img src="<?php bloginfo('stylesheet_directory') ?>/style/images/main_site/banners/services_banners/3.jpg" alt="" />
.............
</div>
My question is how can I throw the div and all those images into my else echo statement? I'm having trouble escaping the quotes and my slider markup isn't rendering.
<div id="banner">
<?php if($regbanner): ?>
<img src="<?php echo $regBannerURL; ?>/style/images/main_site/home_page/mock_banner.jpg" />
<?php else: ?>
<div id="slider">
<img src="<?php echo ($bannerDir = bloginfo('stylesheet_directory') . '/style/images/main_site/banners/services_banners'); ?>/1.jpg" alt="" />
<img src="<?php echo $bannerDir; ?>/2.jpg" alt="" />
<img src="<?php echo $bannerDir; ?>/3.jpg" alt="" />
.............
</div>
<?php endif; ?>
</div><!-- end banner -->
If you don't like the offered solution using the syntaxif(...):...else...endif; you also have the possibilty of using heredoc-style to include bigger html-parts into an echo-statement without the need of escaping it.
The code-formatting in here unfortunatly messed up my example, which I wanted to post. But if you know the heredoc-notation, it should not be a problem ;)

Categories