Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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

  • #2
    New Coder
    Join Date
    Jan 2010
    Location
    Canada
    Posts
    34
    Thanks
    11
    Thanked 4 Times in 4 Posts
    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().

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Do I add that code further up the php code?

  • #4
    New Coder
    Join Date
    Jan 2010
    Location
    Canada
    Posts
    34
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Add that code right after making the query to the database with mysql_query().


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •