$topsellers = mysql_query("SELECT ID,itemgrID,topqty FROM item ORDER BY topqty DESC LIMIT 10") or db_die();
while ($toplijst = mysql_fetch_object($topsellers)) {
$itemname = mysql_query("SELECT name,itemID FROM iteminfo WHERE itemID=".$toplijst->ID) or db_die();
while ($topname = mysql_fetch_object($itemname)) {
$itemabt = mysql_query("SELECT abtID,ID FROM itemgr WHERE ID=".$toplijst->itemgrID) or db_die();
while ($topabt = mysql_fetch_object($itemabt))
it wasn't Jens who built this pure my work with your help of course.....
Jens isn't as smart as he things... ;-)
I also made a track and trace function on the site.....
Before i set the status on 'send' i fill in a tracking number in a textbox.
When a costumer looks at his orders he also has a link to his own tracking page on the site of TPG post.
I've also made a function to change orders......
here is the script.
<?php
$url="changeorder.php";
require("header2.inc.php");
require("../lang/".$lang."_orders.inc.php");
$atable = "<table border=0 cellpadding=4 cellspacing=0 align=center>";
$itable = "<table border=0 cellpadding=2 cellspacing=0 class=grey>";
function formatprice($ufprice) {
global $lang;
if ($lang=="de") {$fprice= number_format($ufprice, 2 , "," , ".");}
else {$fprice = number_format($ufprice , 2 , "." , ",");}
return $fprice;
}
if ($nummer!="") {
#$order_string=explode("/B",$nummer);
#$od = substr($order_string[0],4,2);
#$om = substr($order_string[0],2,2);
#$oy = substr($order_string[0],0,2);
#$order_ltime_s = mktime(0,0,0,$om,$od,$oy);
#$order_ltime_e = $order_ltime_s + 84600;
#$order_number= $order_string[1];
$order_str = encrypt_nr($nummer);
$order_res=db_query("select * from bestell where number='$order_str[0]'") or db_die();
if (db_num_rows($order_res)==0) { exit("Bestelnummer niet gevonden.</body></html>\n"); }
$order_row=db_fetch_row($order_res);
$orderID = $order_row[0];
}
if ($mode=="print") {
$bd_res = db_query("select bill_date from bestell where ID='orderID'") or db_die();
$bd_row = db_fetch_row($bd_res);
if ($bd_row[0] == 0) { $bd_row[0] = mktime(0,0,0,date("m"),date("d"),date("Y"));
$upd_res = db_query("update bestell set bill_date = '$bd_row[0]', stat='pending' where ID='$orderID'") or db_die();
}
}
$order_res=db_query("select * from bestell where ID='$orderID'") or db_die();
$order_row=db_fetch_row($order_res);
$nummer = crypt_nr($order_row[3], $order_row[12]);
$user_res=db_query("select kdnr, firma, firstname, name, street, hnr, country, plz, city, groupID from user where ID='$order_row[1]'") or db_die();
$user_row=db_fetch_row($user_res);
$cur_res=db_query("select keysign2 from currency where ID='$order_row[2]'") or db_die();
$cur_row=db_fetch_row($cur_res);
$grp_res=db_query("select discount from usrgroup where ID='$user_row[9]'") or db_die();
$grp_row=db_fetch_row($grp_res);
$bn=1;
$disc=$grp_row[0];
$stat_res=db_query("select * from statistics where orderID='$orderID'") or db_die();
while ($stat_row = db_fetch_row($stat_res)) {
$stat_row6 = preg_replace("(\.[0]{1,}$)","",$stat_row[6]);
$stat_row8 = $order_row[5]*$stat_row[7]*$stat_row[8];
What i want to show is a list of the most sold products on the website.....
Now has anyone ever developed something like this with phpay 2.0......
With the help of Andreas I made the following code
<?php
$caller="topsell";
require("headerxtr.inc.php");
echo "<u><br><br><font size=\"2\"><strong>PRODUCT TOP10</strong></font></u>\n";
$database_server = mysql_connect("$db_host","$db_user","$db_pass");
mysql_select_db("$db_name", $database_server);
$topsellers = mysql_query("SELECT ID,itemgrID,topqty FROM item ORDER BY topqty DESC LIMIT 10") or db_die();
while ($toplijst = mysql_fetch_object($topsellers)) {
$itemname = mysql_query("SELECT name,itemID FROM iteminfo WHERE itemID=".$toplijst->ID) or db_die();
while ($topname = mysql_fetch_object($itemname)) {
$itemabt = mysql_query("SELECT abtID,ID FROM itemgr WHERE ID=".$toplijst->itemgrID) or db_die();
while ($topabt = mysql_fetch_object($itemabt))
echo "<p></p>\n";
echo "<a href=\"detail.php?sess=$sess&art_id=$toplijst->ID&abt=$topabt->abtID&itemgr=$toplijst->itemgrID\" target=main><img src='pfeile2.gif' border='0' >$topname->name <br>\n";
}
}
?>
It needs a field called topqty in Items..... and i've
made a separate headerfile to go along with it...
I think Jens built this code ... but equal here ...
Looks a little bit overhead. Why don't you use db_query() from db_func.inc.php and connect again to database server?
Greetings,
Andreas.
it wasn't Jens who built this pure my work with your help of course.....
Jens isn't as smart as he things... ;-)
I also made a track and trace function on the site.....
Before i set the status on 'send' i fill in a tracking number in a textbox.
When a costumer looks at his orders he also has a link to his own tracking page on the site of TPG post.
I've also made a function to change orders......
here is the script.
<?php
$url="changeorder.php";
require("header2.inc.php");
require("../lang/".$lang."_orders.inc.php");
$atable = "<table border=0 cellpadding=4 cellspacing=0 align=center>";
$itable = "<table border=0 cellpadding=2 cellspacing=0 class=grey>";
function formatprice($ufprice) {
global $lang;
if ($lang=="de") {$fprice= number_format($ufprice, 2 , "," , ".");}
else {$fprice = number_format($ufprice , 2 , "." , ",");}
return $fprice;
}
if ($nummer!="") {
#$order_string=explode("/B",$nummer);
#$od = substr($order_string[0],4,2);
#$om = substr($order_string[0],2,2);
#$oy = substr($order_string[0],0,2);
#$order_ltime_s = mktime(0,0,0,$om,$od,$oy);
#$order_ltime_e = $order_ltime_s + 84600;
#$order_number= $order_string[1];
$order_str = encrypt_nr($nummer);
$order_res=db_query("select * from bestell where number='$order_str[0]'") or db_die();
if (db_num_rows($order_res)==0) { exit("Bestelnummer niet gevonden.</body></html>\n"); }
$order_row=db_fetch_row($order_res);
$orderID = $order_row[0];
}
if ($mode=="print") {
$bd_res = db_query("select bill_date from bestell where ID='orderID'") or db_die();
$bd_row = db_fetch_row($bd_res);
if ($bd_row[0] == 0) { $bd_row[0] = mktime(0,0,0,date("m"),date("d"),date("Y"));
$upd_res = db_query("update bestell set bill_date = '$bd_row[0]', stat='pending' where ID='$orderID'") or db_die();
}
}
$order_res=db_query("select * from bestell where ID='$orderID'") or db_die();
$order_row=db_fetch_row($order_res);
$nummer = crypt_nr($order_row[3], $order_row[12]);
echo "<div id=pos>";
echo "<table border=0 cellpadding=2 cellspacing=3 width=575>\n";
echo "<tr nowrap><td> </td><td width=\"165\"><div id=abs>\n";
echo "<br> <br> <br> <br> \n";
echo "</div></td></tr><table>\n";
$user_res=db_query("select kdnr, firma, firstname, name, street, hnr, country, plz, city, groupID from user where ID='$order_row[1]'") or db_die();
$user_row=db_fetch_row($user_res);
$cur_res=db_query("select keysign2 from currency where ID='$order_row[2]'") or db_die();
$cur_row=db_fetch_row($cur_res);
$grp_res=db_query("select discount from usrgroup where ID='$user_row[9]'") or db_die();
$grp_row=db_fetch_row($grp_res);
$bn=1;
$disc=$grp_row[0];
echo "<tr><td colspan=2>\n";
echo "<div id=bold>$user_row[1]</div>$user_row[2] $user_row[3]<br>$user_row[4] $user_row[5]\n";
echo "<div id=bold>$user_row[7] $user_row[8]</div><br><br><br><br><br><br><br>\n";
echo "$order_15: $user_row[0]<br><br>\n";
echo "$order_17: $nummer<br>\n";
echo "</td><td colspan=2 align=right valign=bottom nowrap>Beetgumermolen, ";
#if ($order_row[14]==""):
# $billdate = mktime(0,0,0,date("m"),date("d"),date("Y"));
# $bill_date_res = db_query("update bestell set bill_date = '$billdate' where ID='$orderID'") or db_die();
# $order_row[14] = $billdate;
#endif;
if ($order_row[14] != 0) { echo date("d.m.Y", $order_row[14])."</td></tr>\n"; }
else { echo date("d.m.Y")."</td></tr>\n"; }
echo "<tr><td colspan=4><img src=\"../img/filler.gif\" height=35 width=1></td></tr>\n";
$ord_date = date("d. m. Y",$order_row[3]);
echo "<tr><td colspan=4>$order_30 $ord_date</td></tr>\n";
echo "<tr><td colspan=4><hr noshade></td></tr>\n";
echo "<tr><td align=center>$order_19</td><td>$order_31 $order_20</td><td align=right>$order_32</td><td align=right>$order_23</td></tr>\n";
$stat_res=db_query("select * from statistics where orderID='$orderID'") or db_die();
while ($stat_row = db_fetch_row($stat_res)) {
echo "<tr valign=top>";
$stat_row6 = preg_replace("(\.[0]{1,}$)","",$stat_row[6]);
echo "<td align=center>$stat_row6</td>\n";
echo "<td>$stat_row[2] $stat_row[3] ";
if ($stat_row[4]!="") { echo "$stat_row[4] "; }
if ($stat_row[5]!="") { echo "$stat_row[5]"; }
echo "</td>\n";
if ($bn==0) { $sstat_row7 = $stat_row[7]; }
else { $sstat_row7 = $stat_row[7]*$stat_row[8]; }
echo "<td align=right>$cur_row[0] ".formatprice($sstat_row7)."</td>\n";
if ($bn==0) { $stat_row7 = $order_row[5]*$stat_row[6]*$stat_row[7];}
else { $stat_row7 = $order_row[5]*$stat_row[6]*$stat_row[7]*$stat_row[8];}
echo "<td align=right>$cur_row[0] ".formatprice($stat_row7)."</td>\n";
$summe += $stat_row7;
echo "</td></tr>\n";
}
if ($bn==0) { $pm_price = $order_row[8]/1.16; }
else { $pm_price = $order_row[8]; }
if ($bn==0) { $sm_price = $order_row[10]/1.16; }
else { $sm_price = $order_row[10]; }
$summe += $pm_price+$sm_price;
if ($sm_price!=0) {
echo "<tr valign=top><td colspan=3 align=right>$order_25:</td><td align=right>$cur_row[0] ".formatprice($sm_price)."</td></tr>\n";
}
if ($pm_price!=0) {
echo "<tr valign=top><td colspan=3 align=right>$order_33 $order_24:</td><td align=right>$cur_row[0] ".formatprice($pm_price)."</td></tr>\n";
}
echo "<tr><td colspan=4><hr noshade></td></tr>\n";
if ($bn==0) {
echo "<tr valign=top><td colspan=3 align=right>$order_23 (netto):</td><td align=right>$cur_row[0] ".formatprice($summe)."</td></tr>\n";
$mwst = ($summe*1.19)-$summe;
echo "<tr valign=top><td colspan=3 align=right>$order_38:</td><td align=right>$cur_row[0] ".formatprice($mwst)."</td></tr>\n";
echo "<tr valign=top><td colspan=3 align=right>$order_23 (brutto):</td><td align=right>$cur_row[0] ".formatprice($summe+$mwst)."</td></tr>\n";
}
else {
echo "<tr valign=top><td colspan=3 align=right>$order_23:</td><td align=right>$cur_row[0] ".formatprice($summe)."</td></tr>\n";
$mwst = $summe-($summe/1.19);
echo "<tr valign=top><td colspan=4 align=right>$order_37a $cur_row[0] ".formatprice($mwst)." $order_37b.</td></tr>\n";
}
echo"<br><br>";
###############################################################
$stat_res=db_query("select * from statistics where orderID='$orderID'") or db_die();
while ($stat_row = db_fetch_row($stat_res)) {
$stat_row6 = preg_replace("(\.[0]{1,}$)","",$stat_row[6]);
$stat_row8 = $order_row[5]*$stat_row[7]*$stat_row[8];
echo "<form action=orderchanged.php? method=\"post\">\n<input type=hidden name=userID value='$userID'><input type=hidden name=mode value=edit>\n";
echo "<input type=hidden name=langID value='$langID'><input type=hidden name=ID value=\"$stat_row[0]\">\n";
echo "<table border=0 cellpadding=6 cellspacing=2 align=center>\n";
echo "<tr><td>ID St. Artnr. ";
echo "Naam Prijs </td>\n";
echo "<tr><td><input type=hidden name=ID value=\"$stat_row[0]\">$stat_row[0]<input type=text name=namount size=1 maxlength=2 value=\"$stat_row6\"><input type=text name=nartnr size=4 maxlength=4 value=\"$stat_row[2]\">";
echo "<input type=text name=nname size=40 maxlength=60 value=\"$stat_row[3]\"> <input type=text name=nprice size=6 value=".formatprice($stat_row8)." ></td>\n";
if (isset($error)) { echo "<tr><td colspan=4>$error</td></tr>";}
echo "<tr><td colspan=2 align=center><input type=submit value=\"$admin_32\"></td>\n";
echo "<tr><td colspan=4><hr></td></tr></table></form>\n";
}
#############################################################################
$stat_res=db_query("select * from statistics where orderID='$orderID'") or db_die();
while ($stat_row = db_fetch_row($stat_res)) {
$stat_row6 = preg_replace("(\.[0]{1,}$)","",$stat_row[6]);
$stat_row8 = $order_row[5]*$stat_row[7]*$stat_row[8];
echo "<form action=addart.php? method=\"post\">\n<input type=hidden name=userID value='$userID'><input type=hidden name=mode value=edit>\n";
echo "<input type=hidden name=langID value='$langID'><input type=hidden name=ID value=\"$stat_row[0]\">\n";
echo "<table border=0 cellpadding=6 cellspacing=2 align=center>\n";
echo "<b> Artikel toevoegen <b><br>";
echo "<tr><td>orderID St. Artnr. ";
echo "Naam Prijs </td>\n";
echo "<tr><td><input type=text name=addorderID value=\"$stat_row[1]\"><input type=text name=addamount size=1 maxlength=2 ><input type=text name=addartnr size=4 maxlength=4 >";
echo "<input type=text name=addname size=40 maxlength=60 > <input type=text name=addprice size=6 ></td>\n";
if (isset($error)) { echo "<tr><td colspan=4>$error</td></tr>";}
echo "<tr><td colspan=2 align=center><input type=submit value=\"Voeg Toe\"></td>\n";
echo "<tr><td colspan=4><hr></td></tr></table></form>\n";
}
?>
this is the next script ( orderschanged.php)
<?php
require("header2.inc.php");
echo "<meta http-equiv='refresh' content='2; url=orders.php?langID=1'>\n";
$database_server = mysql_connect("$db_host","$db_user","$db_pass");
mysql_select_db("$db_name", $database_server);
$namount = $_POST["namount"];
$nartnr = $_POST["nartnr"];
$nname = $_POST["nname"];
$nprice = $_POST["nprice"];
$ID= $_POST["ID"];{
$upd_res=db_query("update statistics set quantity ='$namount', item_name='$nname', item_number='$nartnr', price_value='$nprice' where ID='$ID'") or db_die();
echo "De order is geupdate \n"; }
?>
I know the script isn't perfect...... it work and after that I din't had more time to finish it........
I still am working on a script to ad new orders..... for I'm opening a store in a few months and I want to use the site in the shop as well....