kyleldi Posted March 13, 2009 Share Posted March 13, 2009 I've got an if statement that I need to replace some characters on before it outputs to the browser, (spaces converted to +), but when I do it, it doesn't output correctly. Any idea where i'm going wrong? do { echo '<div class="thumbframe">'.$row_rs_multi_cats['category'] = str_replace(" ","+",$row_rs_multi_cats['category']).' <div class="thumb"><a href="downloads.php?category='.$row_rs_multi_cats['category'].'"><img src="images/downloads/'.$row_rs_multi_cats['category'].'.jpg" alt="'.$row_rs_multi_cats['category'].'" width="100" height="58" border="0" longdesc="downloads.php?category='.$row_rs_multi_cats['category'].'" /></a></div> <div>'.ucwords($row_rs_multi_cats['category']).'</div></div>'; } while ($row_rs_multi_cats = mysql_fetch_assoc($rs_multi_cats)); } Link to comment https://forums.phpfreaks.com/topic/149225-solved-str_replace-on-if-statement/ Share on other sites More sharing options...
hastishah Posted March 13, 2009 Share Posted March 13, 2009 do { echo '<div class="thumbframe">'.str_replace(" ","+",$row_rs_multi_cats['category']).' <div class="thumb"><a href="downloads.php?category='.$row_rs_multi_cats['category'].'"><img src="images/downloads/'.$row_rs_multi_cats['category'].'.jpg" alt="'.$row_rs_multi_cats['category'].'" width="100" height="58" border="0" longdesc="downloads.php?category='.$row_rs_multi_cats['category'].'" /></a></div> <div>'.ucwords($row_rs_multi_cats['category']).'</div></div>'; } while ($row_rs_multi_cats = mysql_fetch_assoc($rs_multi_cats)); } Regards Hastimal Shah Link to comment https://forums.phpfreaks.com/topic/149225-solved-str_replace-on-if-statement/#findComment-783649 Share on other sites More sharing options...
kyleldi Posted March 13, 2009 Author Share Posted March 13, 2009 The problem it continues to output data and echo it whenever I use '.str_replace(" ","+",$row_rs_multi_cats['category']).' How do I fix this? Thank You! Link to comment https://forums.phpfreaks.com/topic/149225-solved-str_replace-on-if-statement/#findComment-783657 Share on other sites More sharing options...
kenrbnsn Posted March 13, 2009 Share Posted March 13, 2009 Please post more of your code and explain your problem better. Ken Link to comment https://forums.phpfreaks.com/topic/149225-solved-str_replace-on-if-statement/#findComment-783660 Share on other sites More sharing options...
hastishah Posted March 14, 2009 Share Posted March 14, 2009 Hi see check this code its working copy this code in new file and run and check the output <?php $row_rs_multi_cats = array('category'=>"hello world"); echo '<div class="thumbframe">'.$row_rs_multi_cats['category'] = str_replace(" ","+",$row_rs_multi_cats['category']).' <div class="thumb"><a href="downloads.php?category='.$row_rs_multi_cats['category'].'"><img src="images/downloads/'.$row_rs_multi_cats['category'].'.jpg" alt="'.$row_rs_multi_cats['category'].'" width="100" height="58" border="0" longdesc="downloads.php?category='.$row_rs_multi_cats['category'].'" /></a></div> <div>'.ucwords($row_rs_multi_cats['category']).'</div></div>'; ?> Link to comment https://forums.phpfreaks.com/topic/149225-solved-str_replace-on-if-statement/#findComment-784495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.