darkcarnival Posted November 26, 2006 Share Posted November 26, 2006 hi,I have 3 variables that are comming from a loop, when i output this, it slams the items in one shot.for example:id-name1-test2-help3-foowould output astesthelpfoo123how do i kill off this pattern?thanks Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/ Share on other sites More sharing options...
theironchef Posted November 26, 2006 Share Posted November 26, 2006 can you post a little code? the loop and variables perhaps? Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130480 Share on other sites More sharing options...
darkcarnival Posted November 26, 2006 Author Share Posted November 26, 2006 yea i can do that:[code]while($row = mysql_fetch_assoc ($board_query)){ $board_id .= $row['id']; $board_name .= $row['Board']; $board_description .= $row['Description'];}$board_vars = array($board_id, $board_name, $board_description);[/code] Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130483 Share on other sites More sharing options...
kenrbnsn Posted November 26, 2006 Share Posted November 26, 2006 When you use the concatenation operator, " . ", it puts strings together with no separators. How do you want the output to appear?Ken Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130485 Share on other sites More sharing options...
darkcarnival Posted November 26, 2006 Author Share Posted November 26, 2006 i want each value from the loop to be on its on line ;)right now it combines ythem together.couldnt I do something like use explode() or something to do this? Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130487 Share on other sites More sharing options...
.josh Posted November 26, 2006 Share Posted November 26, 2006 this isn't even a php problem it's an html problem. how about throwing in some [code]<br>[/code]tags.p.s. - moving to html forum. Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130490 Share on other sites More sharing options...
darkcarnival Posted November 26, 2006 Author Share Posted November 26, 2006 um its a php problem Crayon Violent,i already tried that and it didnt work. Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130493 Share on other sites More sharing options...
.josh Posted November 26, 2006 Share Posted November 26, 2006 okay..i am assuming you are trying to do something like this (since you (still) haven't shown you're code):[code]$board_vars = array($board_id, $board_name, $board_description);foreach ($board_vars as $val) { echo $val;}[/code]is that about what you're code looks like? Then do this:[code]$board_vars = array($board_id, $board_name, $board_description);foreach ($board_vars as $val) { echo "$val </br>";}[/code]I'm not tryin' to be rude or nothin'. You just need to show your code if you expect people to accurately help with the problem. P.s. - I still insist that it is not a php but an html problem. Unless you have some conditions or something that prevents your (tried) html code from being output: but again, show some code. Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130526 Share on other sites More sharing options...
darkcarnival Posted November 26, 2006 Author Share Posted November 26, 2006 i did show you the code ;)[code]while($row = mysql_fetch_assoc ($board_query)){ $board_id .= $row['id']; $board_name .= $row['Board']; $board_description .= $row['Description'];}$board_vars = array($board_id, $board_name, $board_description);[/code]that is what the function does ;)now adding a br tag will just make the output worse.example of it is:<a href="link.php?id=1(newline)2(newline)3(newline)">link1(newline)link2(newline)link3(newline)</a>it all should be it's own link, which is my present issue.the full code is too lengthy to post here so im only posting the code thats causing the problem. Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130543 Share on other sites More sharing options...
wildteen88 Posted November 26, 2006 Share Posted November 26, 2006 If you want each row to createe a separate link then your whole while loop is wrong. It should be like this:[code]while($row = mysql_fetch_assoc ($board_query)){ $board_id = $row['id']; $board_name = $row['Board']; $board_description = $row['Description']; echo '<a href="link.php?id=' . $board_id . '">' . $board_name . '</a><br />'; echo '<span style="font-size: small">' . $board_description . '</span><br /><br />';}[/code]That should now print out a link for each board with its description. Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130548 Share on other sites More sharing options...
darkcarnival Posted November 26, 2006 Author Share Posted November 26, 2006 ok I'll try thathopefully that'll solve my problem. Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-130554 Share on other sites More sharing options...
Renlok Posted November 27, 2006 Share Posted November 27, 2006 it is a html problem if you print it like[code]$board_vars = array($board_id, $board_name, $board_description);[/code]its obviously going to come out in one line as theres nothing showing it has to print onto the next line. Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-131171 Share on other sites More sharing options...
darkcarnival Posted November 28, 2006 Author Share Posted November 28, 2006 i was trying to do something but it looks like i cant do it the way i want to do it.i got it working the way i want now, thanks to those who helped.btw it was both a PHP & HTML problem :PMarking as Solved and locking the topic Link to comment https://forums.phpfreaks.com/topic/28517-solvedarray-problem/#findComment-131238 Share on other sites More sharing options...
Recommended Posts