/    Sign up×
Community /Pin to ProfileBookmark

query result duplications

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”?>[/url]
</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”>
<a><button name=”open” value=”none” type=”submit”>create</button></a></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);
?>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleNov 21.2007 — How about ordering your results by the sddoco? Then your $check thing should work 100% of the time. Also, you have overlapping tags everywhere. <td><font></td></font> is not good.
×

Success!

Help @dkirk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...