ecopetition Posted August 20, 2009 Share Posted August 20, 2009 Hi there, I have the following code for generating a list of smilies based on rows in a database table: function generate_smiley_list() { global $db, $template, $config; $sql = "SELECT * FROM smilies WHERE show_list = 1"; $result = $db->query($sql); while($row = $db->fetch_assoc($result)) { $template->assign_block_vars('smilies', array( 'SMILEY_PATH' => $config['smiley_root'] .'/'. $row['image'] . $row['image_extension'], 'SMILEY_NAME' => $row['name'], 'SMILEY_ID' => $row['id'] )); } } How can I have the array pause every 5 or so smilies and add a line break to avoid each row of smilies becoming overcrowded? Thanks a lot Eco Quote Link to comment https://forums.phpfreaks.com/topic/171203-ordering-a-generated-image-list/ Share on other sites More sharing options...
ecopetition Posted August 21, 2009 Author Share Posted August 21, 2009 Hi, I hate to bump a topic but is there anyone who could help me with this please? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/171203-ordering-a-generated-image-list/#findComment-903339 Share on other sites More sharing options...
ignace Posted August 21, 2009 Share Posted August 21, 2009 Add a counter $i and on each iteration increment it $i++ then if ($i % 5 == 0) add line break. Other option is using a combination of html and css create a list <ul> or <ol> add each item to a <li>. In CSS say ul li { display: inline } this will let the <li> act like an inline element so if it reaches the end of the box it will jump to a new line. Quote Link to comment https://forums.phpfreaks.com/topic/171203-ordering-a-generated-image-list/#findComment-903358 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.