equipment Posted April 23, 2012 Share Posted April 23, 2012 <?php # This database request does get included into the file: knuffix_list_category_sort_automatic_1.php # for the sake of printing the tags list. # Printing of the tag names in ascending order by tag_id $db_connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $sql_get = "SELECT DISTINCT tag_id, tag_name FROM tags ORDER BY tag_id ASC"; $sql_run = mysqli_query($db_connect, $sql_get); # $sql_assoc_tag_id = mysqli_fetch_assoc($sql_run); ?> <div id="labels"> <a href="?cat=All">all</a> <?php while($sql_assoc = mysqli_fetch_assoc($sql_run)){ echo '<u>|</u>' . '<a href="?cat=' . $sql_assoc['tag_id'] . '">' . $sql_assoc['tag_name'] . '</a>'; } ?> </div> The list created in the while loop is breaking out of the div wrapper, even though it should not. It should break into new lines at the side of the div wrapper. What is causing it to not break at the side of the div wrapper? And how can I solve it? Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/ Share on other sites More sharing options...
ManiacDan Posted April 23, 2012 Share Posted April 23, 2012 This is not at all a PHP question, so I'm moving it to the HTML/CSS section. Reply to this and paste the resulting HTML of this output, along with relevant CSS. The PHP loop probably works fine, but none of this HTML is styled (and there's no div at all) so we need to see the actual HTML output. Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/#findComment-1339751 Share on other sites More sharing options...
equipment Posted April 23, 2012 Author Share Posted April 23, 2012 I thought of it as not an HTML or CSS problem, that is the reason why I suspected the while loop for this case. Take a look at the live example here: http://www.emoticonsymbols.net/model/contribution/knuffix_list.php?cat=All The two series of tags above and below are in the exact same div with the exact same id="labels", though the lower one which is being printed off the while loop does break out. Developer tools can be used for the HTML or CSS. Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/#findComment-1339759 Share on other sites More sharing options...
haku Posted April 23, 2012 Share Posted April 23, 2012 PHP outputs HTML. The browser interprets HTML. The browser does not even know of the existence of PHP - for all the browser knows, it could be a magic elf sending the HTML, or an .asp script, or perl, or PHP. So when you have a display issue, it's either css or html. Post the output of your PHP script here. Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/#findComment-1339775 Share on other sites More sharing options...
equipment Posted April 23, 2012 Author Share Posted April 23, 2012 I already posted it, do look at the link in the post above yours. Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/#findComment-1339786 Share on other sites More sharing options...
ManiacDan Posted April 23, 2012 Share Posted April 23, 2012 There's no whitespace in your output, so the browser cannot break because this is one long word. Put a single space after your vertical pipe, and it will work fine. Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/#findComment-1339827 Share on other sites More sharing options...
equipment Posted April 23, 2012 Author Share Posted April 23, 2012 What is a "vertical pipe"? Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/#findComment-1339835 Share on other sites More sharing options...
ManiacDan Posted April 23, 2012 Share Posted April 23, 2012 | is a vertical pipe. Put a space in here: echo '<u>|</u>' Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/#findComment-1339840 Share on other sites More sharing options...
equipment Posted April 23, 2012 Author Share Posted April 23, 2012 Thanks a lot, I have to say that putting the space before the vertical pipe will work better because it will keep the vertical pipe with the tag together, they can both break apart at the breaking point if the space will be after the vertical pipe. Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/#findComment-1339845 Share on other sites More sharing options...
ManiacDan Posted April 23, 2012 Share Posted April 23, 2012 Wherever you put it, there needed to be a space. Quote Link to comment https://forums.phpfreaks.com/topic/261454-created-list-in-the-while-loop-breaks-out-of-the-div-wrapper/#findComment-1339868 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.