Witzbold Posted February 18, 2008 Share Posted February 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
trq Posted February 18, 2008 Share Posted February 18, 2008 Try using.... if ($row['active'] == 1) { instead of..... if({$row['active']}=1 { Quote Link to comment Share on other sites More sharing options...
Witzbold Posted February 18, 2008 Author Share Posted February 18, 2008 That worked, that you very much. I knew it was something simple, guess I just need to dive more into context so I don't make that mistake again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.