Jump to content

Getting different text depending on active field in an echo


Witzbold

Recommended Posts

Hi,

  I am new to coding PHP and using MySQL I am designing a page to display some information from a database onto the page.  I have tried to figure out this problem before asking for help, but I think I've come to a standstill with my knowledge.  I am trying to get a section of code to changed depending on the active field.  If the field is set to 1 (active) I want a player link and a download link, if the active field is 0 (unactive) I want only [Archived] to appear.

 

Example: If Active=1

John Urban Show (show date) [PLAYER LINK][DOWNLOAD LINK]

Show desription

 

If Active=0

John Urban Show (show date) [archived]

Show desription

 

 

<?php
include 'connect.php';

$query  = "SELECT show_num, orig_date, show_desc, filename, active FROM `show` WHERE year=2008" ;
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
    echo "John Urban Show #{$row['show_num']} ({$row['orig_date']});"
if({$row['active']}=1 {
echo "[<a href=\"http://myurl.com/pc/{$row['filename']}\">Download Show</a>] [<a href=\"http://myurl.com/player.php?id={$row['show_num']}\">Listen in Player</a>] <br>" . 
       	 }
echo "[Archived]<br>" .	 
echo "Show Descript : {$row['show_desc']} <br><br>";
} 

?> 

 

I am pretty sure that this probably isn't hard, but with being as new with programing with this as I am, I can't figure this out,  any help would be greatly appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.