kingnothing Posted July 7, 2010 Share Posted July 7, 2010 hello this is my first post here , i have a website where i display videos with the option to download it wmv recently i added a new table to the database and added a link to download in mp3 <a href='$mp3'>$lang_t202</a> it works great but the problem is some videos dont have a link for mp3 that makes an empty href leading the vistors to the main page and getting them confused is there a way to get around this ? disable href if its empty ? i tried using this if($mp3 != "") echo "<a href='$mp3'>$lang_t202</a>"; else echo $lang_t202;[/code] and this is the place where i want to put it but it dosnt work i am beginner in all this btw [code=php:0]$F .= "<div align='center'> <center> <table class='xtable' width='100%' id='AutoNumber1f5'> <tr> <td style='text-align:center' colspan='3' height='50' width='100%' class='xtr'>$lang_t200</td> </tr> <tr> <td width='30%' width='30%' class='xtr'><img src='$folder/icons/table.gif' border='0' alt='$lang_t44' title='$lang_t44'> $lang_t44 :</td> <td width='35%' class='xtd'><a href='$url'>$lang_t201</a> | [color=red](I WANT TO ADD IT HERE!!!!!)[/color] </td> </tr> <tr> <td width='30%' width='30%' class='xtr'><img src='$folder/icons/table.gif' border='0' alt='$lang_t45' title='$lang_t45'> $lang_t45 :</td> <td width='70%' class='xtd'>$catnamef</td> </tr> <tr> <td width='30%' width='30%' class='xtr'><img src='$folder/icons/table.gif' border='0' alt='$lang_t2' title='$lang_t2'> $lang_t2 :</td> <td width='70%' class='xtd'>$vis</td> </tr> </table> </center> </div>"; [/code] Link to comment https://forums.phpfreaks.com/topic/207043-how-to-disable-href-in-certain-cases/ Share on other sites More sharing options...
gwolgamott Posted July 7, 2010 Share Posted July 7, 2010 EDIT: I missed an entire section... my bad.... below is the adjusted code to make that right. Sorry about that. I added ended the string belonging to $F then add parts of it at a time Give it a try: $F .= "<div align='center'> <center> <table class='xtable' width='100%' id='AutoNumber1f5'> <tr> <td style='text-align:center' colspan='3' height='50' width='100%' class='xtr'>$lang_t200</td> </tr> <tr> <td width='30%' width='30%' class='xtr'><img src='$folder/icons/table.gif' border='0' alt='$lang_t44' title='$lang_t44'> $lang_t44 :</td> <td width='35%' class='xtd'><a href='$url'>$lang_t201</a> | [color=red]"; // NOTICE I ENDED THE STRING HERE... I ADD IN THE IF STATEMENTS to the string //Do what you already thought of doing right here so it Adds here in right spot if($mp3 != ""){ $F = $F."<a href='$mp3'>$lang_t202</a>"; } if($mp3 == ""){$F= $F.$lang_t202;} //finish adding to the $F string. $F = $F." [/color] </td> </tr> <tr> <td width='30%' width='30%' class='xtr'><img src='$folder/icons/table.gif' border='0' alt='$lang_t45' title='$lang_t45'> $lang_t45 :</td> <td width='70%' class='xtd'>$catnamef</td> </tr> <tr> <td width='30%' width='30%' class='xtr'><img src='$folder/icons/table.gif' border='0' alt='$lang_t2' title='$lang_t2'> $lang_t2 :</td> <td width='70%' class='xtd'>$vis</td> </tr> </table> </center> </div>"; Link to comment https://forums.phpfreaks.com/topic/207043-how-to-disable-href-in-certain-cases/#findComment-1082619 Share on other sites More sharing options...
gwolgamott Posted July 7, 2010 Share Posted July 7, 2010 I had to edit it... was looking at it completely wrong my bad. I fixed it in the previous post though incase you looked at it prior to me adjusting that. Link to comment https://forums.phpfreaks.com/topic/207043-how-to-disable-href-in-certain-cases/#findComment-1082621 Share on other sites More sharing options...
scaleautostyle Posted July 7, 2010 Share Posted July 7, 2010 I habe a question. do you have a file to download for all video or some have a mp3 and other doesn't have?? yours sebastien Link to comment https://forums.phpfreaks.com/topic/207043-how-to-disable-href-in-certain-cases/#findComment-1082622 Share on other sites More sharing options...
kingnothing Posted July 7, 2010 Author Share Posted July 7, 2010 this worked great thank you Link to comment https://forums.phpfreaks.com/topic/207043-how-to-disable-href-in-certain-cases/#findComment-1082628 Share on other sites More sharing options...
marcus Posted July 7, 2010 Share Posted July 7, 2010 You should really minimize that code <?php $link = ($mp3 == "") ? $lang_t202 : '<a href="'.$mp3.'">'.$lang_t202.'</a>'; $F = "<div align='center'> <center> BLAH BLAH ALL YOUR OTHER HTML HERE ".$link." REST OF YOUR HTML </center></div>"; ?> Link to comment https://forums.phpfreaks.com/topic/207043-how-to-disable-href-in-certain-cases/#findComment-1082632 Share on other sites More sharing options...
kingnothing Posted July 7, 2010 Author Share Posted July 7, 2010 You should really minimize that code <?php $link = ($mp3 == "") ? $lang_t202 : '<a href="'.$mp3.'">'.$lang_t202.'</a>'; $F = "<div align='center'> <center> BLAH BLAH ALL YOUR OTHER HTML HERE ".$link." REST OF YOUR HTML </center></div>"; ?> this is a good idea thank you all for the help Link to comment https://forums.phpfreaks.com/topic/207043-how-to-disable-href-in-certain-cases/#findComment-1082645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.