Jump to content

Do Something Every x Records


benhodgson

Recommended Posts

I have the following piece of code, designed for the print-out of ID cards for a member system.

[code]
$query="SELECT * FROM memb WHERE id_printed='0'";
$result=mysql_query($query) or die("<strong>Error ".mysql_errno().":</strong><br> ".mysql_error()."<br><br>\nQuery: $query");

$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {

$id=mysql_result($result,$i,"id");
$first=mysql_result($result,$i,"first_name");
$last=mysql_result($result,$i,"surname");
$exec_pos=mysql_result($result,$i,"exec_pos");
$day=mysql_result($result,$i,"joined_day");
$month=mysql_result($result,$i,"joined_month");
$year=mysql_result($result,$i,"joined_year");
$image=mysql_result($result,$i,"image");

if(empty($image)){
$image = "http://www.demonfm.co.uk/images/members/membphotos/nophoto.gif";
}

if (!($exec_pos=='') && !($exec_pos=='None') && !($exec_pos=='none'))
{
echo "
<div class=\"idmem\">
<div class=\"extimg\">
<img src=\"name.png\" alt=\"name\" />
</div>
<div class=\"fbg\">
<img src=\"fbg.png\" alt=\"fieldbg\" />
</div>
<div class=\"fname\">
<span class=\"text\">$first $last</span>
</div>
<div class=\"extimg\">
<img src=\"valid.png\" alt=\"validuntil\" />
</div>
<div class=\"fbg\">
<img src=\"fbg.png\" alt=\"fieldbg\" />
</div>
<div class=\"fjoin\">
<span class=\"text\">$day $month $year</span>
</div>
<div class=\"extimg\">
<img src=\"exec.png\" alt=\"execpos\" />
</div>
<div class=\"fbg\">
<img src=\"fbg.png\" alt=\"fieldbg\" />
</div>
<div class=\"fjoin\">
<span class=\"text\">$exec_pos</span>
</div>
<div class=\"exfid\">
<span class=\"id\">$id</span>
</div>
<div class=\"exfpic\">
<img src=\"$image\" width=\"99\" height=\"128\" alt=\"memberpic\" /><br />
<img class=\"logo\" src=\"logo.png\" alt=\"demonlogo\" />
</div>
</div>
";
}
else
{
echo "
<div class=\"idmem\">
<div class=\"timg\">
<img src=\"name.png\" alt=\"name\" />
</div>
<div class=\"fbg\">
<img src=\"fbg.png\" alt=\"fieldbg\" />
</div>
<div class=\"fname\">
<span class=\"text\">$first $last</span>
</div>
<div class=\"timg\">
<img src=\"valid.png\" alt=\"validuntil\" />
</div>
<div class=\"fbg\">
<img src=\"fbg.png\" alt=\"fieldbg\" />
</div>
<div class=\"fjoin\">
<span class=\"text\">$day $month $year</span>
</div>
<div class=\"fid\">
<span class=\"id\">$id</span>
</div>
<div class=\"fpic\">
<img src=\"$image\" width=\"99\" height=\"128\" alt=\"memberpic\" /><br />
<img class=\"logo\" src=\"logo.png\" alt=\"demonlogo\" />
</div>
</div>
";
}

$i++;
}
[/code]

8 cards will fit onto a single A4 sheet of paper. The problem is that the next two cards then span across two sheets, cutting them in half.

Is there any way to insert a blank space (Probably as an image or empty DIV) every 8 records to push the next two cards down to the next page and, based on the code above, what would be the easiest way to do this?

Thanks in advance.
Link to comment
Share on other sites

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.