/    Sign up×
Community /Pin to ProfileBookmark

if statement help

Hi Everyone,

I have a random script that displays a image red x versus my No Picture Available image.

The script suppose to match the id of #__estateagent_object with the img_id of #__estateagent_images and return the information to include image.

Now if no images have been uploaded there will be no img_id found in #__estateagent_images and should return the No Pic Available. But, its not working.

I think my IF STATEMENT is incorrect. Any suggestions would be gratefully appreciated.

[CODE]
$picturepath = $mosConfig_live_site.$ea_picpath.”/”;

$query=”SELECT * FROM #__estateagent_object WHERE obj_publish=’1′ ORDER BY rand() LIMIT 1″;
$database->setQuery( $query );
$rows = $database->loadObjectList();
$row=$rows[0];

$query1=”SELECT img_id, obj_img1 FROM #__estateagent_images WHERE img_id=$row->id “;
$database->setQuery( $query1 );
$rows1 = $database->loadObjectList();
$row1=$rows1[0];

$query2=”SELECT * FROM #__estateagent_category WHERE cat_id=$row->obj_cat”;
$database->setQuery( $query2 );
$rows2 = $database->loadObjectList();
$row2=$rows2[0];

if($img_id != ‘$row->id’) {
$sm_pic = “<img src='”.$picturepath.”thmb_”.$row1->obj_img1.”‘ border=’0′ alt=’$row->obj_title’>”;
}
else {
$sm_pic = “<img src='”. $mosConfig_live_site.”/components/com_estateagent/obj_pictures/nopic.png’ border=’0′ alt=’$row->obj_title’>”;
}

echo “<center><a href=’index.php?option=com_estateagent&Itemid=0&func=showObject&objid=$row->id’><b>$row2->cat_name</b><br/>$sm_pic<br/><font size=’1′>”.$row->obj_town.”, “.$row->obj_state.”</font></a></center>”;

[/CODE]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Paul_JrSep 20.2004 — Variables inclosed within single quotes will not be parsed -- in other words, try removing the quotes from around [font=courier]'$row->id'[/font].
Copy linkTweet thisAlerts:
@ivainsauthorSep 20.2004 — Thanks a bunch Paul Jr. I don't believe it was something as simple as that. Thanks again!
Copy linkTweet thisAlerts:
@Paul_JrSep 20.2004 — You're welcome. ?
×

Success!

Help @ivains spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...