Jump to content

Recommended Posts

i have developed a program to group package, serial no. and expire day of package. but i face one issue, during group by same package name but the expire day is different. the program will group it as a same package without differentiate the expire day.

below is the my coding that group different package with different expire day.

$result3 = mysql_query("SELECT package, serialNo, expireDay FROM orderdetail WHERE resellerID = '$resellerID' AND orderNo='$orderNo' order by package, serialNo");

$data = array();

while (list($p, $s, $e) = mysql_fetch_row($result3))
{
echo $data[$p][] = $s;
}

foreach($data as $pkg => $s_array)
{
$num = count($s_array);
$serial= listSerNums($s_array,0);
$resultvalue = mysql_query("select package, valuedesc, pricePerUnit from batch a, prepaidcard b where a.batchNo = b.batchNo and b.serialNo in ($serial)") or die(mysql_error());
$rowvalue = mysql_fetch_array($resultvalue);
}

function listSerNums($sers, $n)
{
$i = 1;
$j = 1;
$x = count($sers);
foreach ($sers as $s)
{
if ($j++ == $x)
{
$res .= $s;
}
else
{
$res .= $s . ', ';
}
if ($n != 0)
{
if ($i++ % $n == 0) $res .= '<br />';
}
}
return $res;
}

The result data for $result3 is as below : -
package serialNo expireday
pr_unlimited 1000 1
pr_unlimited 1001 1
pr_unlimited 1010 7
pr_unlimited 1011 7
pr_Oneday 1020 1
pr_Oneday 1021 1

How to group the package as below : -
package expireday serialNo
pr_unlimited 1 1000,1001
pr_unlimited 7 1010,1011
pr_Oneday 1 1020,1021

Please advise. Thanks.
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.