Jump to content

Recommended Posts

Alright gang, This one has me baffled and I am hoping someone will take the time to help me figure this out. This script is selecting order numbers from a db based off of the order type and the time period that the order was placed. The table that I am searching archives every line item for each order, there is a part number field and a order number field for every record. So if there are 10 items on the order, the order number will appear 10 times in the table. At this point, I am only concerned with the order number itself and I do not want the order number to duplicate in my results from the query.  Please see the code below, pay attention to the $check and the $ordernum variables. I am using the $check variable to eliminate the duplications in the while loop but for whatever reason, it does not always work. 95% of the time it works but I need it to work every time. Does anyone have any better ideas for eliminating duplications?

 

<?

$check = "";

$countrec = 1;

            $warque = "SELECT sddoco, sddcto, sdshan, sdivd, sdrcd FROM query1 WHERE sdivd >= $from AND sdivd <= $to AND sdrcd LIKE '$warcode'";

            $result4 = odbc_exec($warcon, $warque);

            while (odbc_fetch_row($result4)){

        $ordernum = odbc_result($result4, 1);

        $ordertype = odbc_result($result4, 2);

        $shipto = odbc_result($result4, 3);

        $ivdcode = odbc_result($result4, 4);

        $reason = odbc_result($result4, 5);                                              

if (($ordernum != $check) AND ($ordertype != "CR") AND ($ordertype != "CV") AND ($ordertype != "CW")){

?>

<tr>

<td align="center"><font color="#666666" face="Tahoma"><?echo $countrec++?></td></font>

<td align="center"><font face="Tahoma">

<a href='<?print ("warorder.php?ordernum=$ordernum&ordertype=$ordertype&date=$date&shipto=$shipto&reason=$reason&custname=$custname");?>'title="<?echo "$ordernum $ordertype"?>" target='_blank'><?echo "$ordernum $ordertype"?></a>

</td></font>

<td align="center"><font color="#666666" face="Tahoma"><?echo $reason?></td></font>

<td align="center"><font color="#666666" face="Tahoma"><?echo $custname?></td></font>

<td align="center"><font color="#666666" face="Tahoma"><?echo $date?></td></font>

<td width="20" align="center"><font size= face="Tahoma">

<b><a><button name="open" value="none" type="submit">create</button></a></b></font>

<input type="hidden" name="ordernum" value='<?print ("$ordernum");?>'>

<input type="hidden" name="ordertype" value='<?print ("$ordertype");?>'>

<input type="hidden" name="date" value='<?print ("$date");?>'>

<input type="hidden" name="reason" value='<?print ("$reason");?>'>

<input type="hidden" name="month" value='<?print ("$month");?>'>

<input type="hidden" name="year" value='<?print ("$year");?>'>

<input type="hidden" name="shipto" value='<?print ("$shipto");?>'>

<input type="hidden" name="custname" value='<?print ("$custname");?>'>

</td>

</tr>

<?

}

$check = $ordernum;

}

odbc_close($connect);

odbc_close($warcon);

?>

Link to comment
https://forums.phpfreaks.com/topic/78289-solved-duplications/
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.