Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-07-2012, 02:19 AM   PM User | #1
Trailerpulse
New to the CF scene

 
Join Date: Oct 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Trailerpulse is an unknown quantity at this point
Only post code if MySQL row data exists?

I have this code on my website that grabs the "official" MySQL database row data and spits it out as a clickable link.

The problem is that if the "official" MySQL row is empty, the code spits out the current website page URL.

Is there a way to edit the below code so that it only spits out the below code if there is data in the mysql "official" row?

I'm guessing some sort of IF statement?

PHP Code:
<div class="movietitles"><img src="/images/35genre.png" />Official Site: <a href="{$official}">link</a></div
Trailerpulse is offline   Reply With Quote
Old 10-07-2012, 03:00 AM   PM User | #2
Cloud Ghost
New Coder

 
Join Date: Jan 2010
Location: Canada
Posts: 34
Thanks: 11
Thanked 4 Times in 4 Posts
Cloud Ghost is an unknown quantity at this point
PHP Code:
$num mysql_num_rows($myquery);
if(
$num 0) {
    
// More than one row was returned.

Replace $myquery with the variable assigned to mysql_query().
Cloud Ghost is offline   Reply With Quote
Old 10-07-2012, 03:06 AM   PM User | #3
Trailerpulse
New to the CF scene

 
Join Date: Oct 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Trailerpulse is an unknown quantity at this point
Do I add that code further up the php code?
Trailerpulse is offline   Reply With Quote
Old 10-07-2012, 03:41 AM   PM User | #4
Cloud Ghost
New Coder

 
Join Date: Jan 2010
Location: Canada
Posts: 34
Thanks: 11
Thanked 4 Times in 4 Posts
Cloud Ghost is an unknown quantity at this point
Add that code right after making the query to the database with mysql_query().
Cloud Ghost is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:20 PM.


Advertisement
Log in to turn off these ads.