Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/171203-ordering-a-generated-image-list/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.