russthebarber Posted December 23, 2009 Share Posted December 23, 2009 i am having to use a javascript function to make an html form 'submit' button look like a link. this is working fine on its own. the problem is when i combine this with some php (first) its putting the link on a separate line. can anyone see where the problem is in my code. if(strlen($str) > $chars) {echo end(array_reverse(explode("\n", wordwrap($str, $chars)))) . ' ...'; ?> <a href="javascript:getsupport('<? echo $row ['id']; ?>')"><div style="color:#FFFFFF; font-size:9px">more</div></a> ///end of relevant code. there is more code at the bottom if this is not clear. i'm getting this: bla bla bla bla bla... more i should be getting this: bla bla bla bla bla...more ///here's some more of the code <table border="0" align="left" cellpadding="0" cellspacing="0" height="122" width="494" background="img/bgbox2_494x1.jpg"> <tr> <td height="11"></td> </tr> <form name="supportform" method="post" action="newsmore.php"> <input type="hidden" name="id" /> <? $counter="0"; while($row = mysql_fetch_array($result)) { $counter=$counter+1; if($counter == "1") {$bg="img/bgbox2_494x1.jpg";} if($counter == "2") {$bg="img/bgbox2_494x1b.jpg";} if($counter == "3") {$bg="img/bgbox2_494x1.jpg";} if($counter == "4") {$bg="img/bgbox2_494x1b.jpg";} if($counter == "5") {$bg="img/bgbox2_494x1.jpg";} ?> <tr> <td background="<? print("$bg"); ?>" height="20"><div style="color:#FFFFFF; margin-left:15px; margin-right:15px; font-family:Arial, Verdana, Helvetica, sans-serif; font-size:9px"> <? $str = $row['entry_date'] . $spacer . $row['maintext']; if(strlen($str) > $chars) {echo end(array_reverse(explode("\n", wordwrap($str, $chars)))) . ' ...'; ?> <a href="javascript:getsupport('<? echo $row ['id']; ?>')"><div style="color:#FFFFFF; font-size:9px">more</div></a> <? } else {echo $str . '... <a href="#">more</a>';} ?> </div> </td> </tr> </form> <? } ?> <tr><td height="11"></td></tr> </table> Link to comment https://forums.phpfreaks.com/topic/186184-php-and-html-on-different-lines/ Share on other sites More sharing options...
TheBurtle Posted December 23, 2009 Share Posted December 23, 2009 Try this... <div style="color:#FFFFFF; font-size:9px"><a href="javascript:getsupport('<? echo $row ['id']; ?>')">more</a></div> Edit: Oops. There we go. Fixed. Link to comment https://forums.phpfreaks.com/topic/186184-php-and-html-on-different-lines/#findComment-983301 Share on other sites More sharing options...
russthebarber Posted December 23, 2009 Author Share Posted December 23, 2009 Thanks Burtle. That's unfortunately made no difference though Link to comment https://forums.phpfreaks.com/topic/186184-php-and-html-on-different-lines/#findComment-983306 Share on other sites More sharing options...
TheBurtle Posted December 23, 2009 Share Posted December 23, 2009 Let's try one more thing... <table border="0" align="left" cellpadding="0" cellspacing="0" height="122" width="494" background="img/bgbox2_494x1.jpg"> <tr> <td height="11"></td> </tr> <form name="supportform" method="post" action="newsmore.php"> <input type="hidden" name="id" /> <? $counter="0"; while($row = mysql_fetch_array($result)) { $counter=$counter+1; if($counter == "1") {$bg="img/bgbox2_494x1.jpg";} if($counter == "2") {$bg="img/bgbox2_494x1b.jpg";} if($counter == "3") {$bg="img/bgbox2_494x1.jpg";} if($counter == "4") {$bg="img/bgbox2_494x1b.jpg";} if($counter == "5") {$bg="img/bgbox2_494x1.jpg";} ?> <tr> <td background="<? print("$bg"); ?>" height="20"><div style="color:#FFFFFF; margin-left:15px; margin-right:15px; font-family:Arial, Verdana, Helvetica, sans-serif; font-size:9px"> <? $str = $row['entry_date'] . $spacer . $row['maintext']; if(strlen($str) > $chars) { echo end(array_reverse(explode("\n", wordwrap($str, $chars)))) . ' ...'; ?> <div style="color:#FFFFFF; font-size:9px"> <a href="javascript:getsupport('<? echo $row ['id']; ?>')"> more </a> </div> <? } else {echo $str . '... <a href="#">more</a>';} ?> </div> </td> </tr> </form> <? } ?> <tr><td height="11"></td></tr> </table> Link to comment https://forums.phpfreaks.com/topic/186184-php-and-html-on-different-lines/#findComment-983310 Share on other sites More sharing options...
russthebarber Posted December 23, 2009 Author Share Posted December 23, 2009 ....no, still the same problem. :'( Link to comment https://forums.phpfreaks.com/topic/186184-php-and-html-on-different-lines/#findComment-983313 Share on other sites More sharing options...
TheBurtle Posted December 23, 2009 Share Posted December 23, 2009 The only other thing I can see is this: echo end(array_reverse(explode("\n", wordwrap($str, $chars)))) . ' ...'; ?> The wordwrap() function defaults to 75 characters, I think, before adding a \n. Not sure, though. Hard to tell without knowing how $chars is defined. Link to comment https://forums.phpfreaks.com/topic/186184-php-and-html-on-different-lines/#findComment-983315 Share on other sites More sharing options...
russthebarber Posted December 23, 2009 Author Share Posted December 23, 2009 $chars is set to 95. when i change to 45 or another value it makes no difference. i have just see your query on pattern searching. i may have some help for you in a minute or two. Link to comment https://forums.phpfreaks.com/topic/186184-php-and-html-on-different-lines/#findComment-983319 Share on other sites More sharing options...
TheBurtle Posted December 23, 2009 Share Posted December 23, 2009 On the output line: echo end(array_reverse(explode("\n", wordwrap($str, $chars)))) . ' ...'; ?> Have you tried to capture the actual output to check for odd newlines and exact HTML code? Sorta like: $array = array(); $array[0] = end(array_reverse(explode("\n", wordwrap($str, $chars)))) . ' ...'; echo end(array_reverse(explode("\n", wordwrap($str, $chars)))) . ' ...'; ?> <!-- hidden <? print_r($array); ?> --> If you could, would you post the print_r output? Link to comment https://forums.phpfreaks.com/topic/186184-php-and-html-on-different-lines/#findComment-983322 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.