<TITLE>What do you say about this?</TITLE>
<BODY BGcolor=BLACK TEXT=WHITE>

<CENTER>

<FORM ACTION="parts.msql">
<INPUT TYPE="HIDDEN" NAME="selected" VALUE="-1">

<!

$dm=5.7;

$color1="NAVY";
$color2="BLUE";
$color3="#99CCCC";
$color4="RED";


$err="";

   $sock=msqlConnect();
   if ($sock<0) {
      echo("<CENTER><TABLE WIDTH=500 BORDER=2 BGCOLOR=\"$color3\">\n");
      echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
      exit(0);
      }

   if (msqlSelectDB($sock, "babba")<0) {
      echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=$color3>\n");
      echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
      exit(0);
      }

$cena=0;
if (#$selected>1) {
   $n=0;
   echo("<TABLE WIDTH=80%>\n<TR><TD COLSPAN=3>Izabrana konfiguracija:</TD></TR>\n");
   echo("<TR><TD COLSPAN=3><HR WIDTH=100%></TD></TR>\n");
   while($n<#$selected) {
      if ((int)$selected[$n]>0) {
      if (msqlQuery($sock, "SELECT * FROM parts WHERE no=$selected[$n]")<0) {
         echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=$color3>\n");
         echo("<TR><TD>\n<BR><CENTER><B>WARNING:</B> $ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
         exit(0);
         }
      $fd=msqlStoreResult();
      $part=msqlFetchRow($fd);
    
      echo("<TR><TD></TD><TD>$part[2]</TD><TD>$part[3]</TD></TR>");

      $cena=$cena+(int)$part[3];

      msqlFreeResult($fd);
      }
      $n=$n + 1;
   }

   echo("<TR><TD COLSPAN=3><HR WIDTH=100%></TD></TR>\n");
   echo("<TR><TD></TD><TD>Ukupna cena (Dm)</TD><TD>$cena</TD></TR>\n");
   $dinara=$cena*$dm;
   echo("<TR><TD></TD><TD>Ukupna cena (din)</TD><TD>$dinara</TD></TR>\n");

   echo("</TABLE>\n");

   exit(0);
   }

if (msqlQuery($sock, "SELECT * FROM grupe")<0) {
   echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=$color3>\n");
   echo("<TR><TD>\n<BR><CENTER><B>WARNING:</B> $ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
   exit(0);
   }

$fd=msqlStoreResult();
$grupa=msqlFetchRow($fd);

while(#$grupa>0) {
   echo("$grupa[2]<BR>\n");
   if (msqlQuery($sock, "SELECT * FROM parts WHERE gid=$grupa[0]")<0) {
      echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=$color3>\n");
      echo("<TR><TD>\n<BR><CENTER><B>WARNING:</B> $ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
      exit(0);
      }
   $sd=msqlStoreResult();
   $part=msqlFetchRow($sd);
   echo("<TABLE width=80%>\n<TR><TD WIDTH=5%></TD><TD>Part</TD><TD WIDTH=10%>Price</TD></TR>\n");
   echo("<TR><TD COLSPAN=3><HR WIDTH=100%></TD></TR>\n");
   while(#$part>0) {
   echo("<TR><TD><INPUT TYPE=\"CHECKBOX\" VALUE=\"$part[0]\" NAME=\"selected\"></TD><TD>$part[2]</TD><TD>$part[3]</TD></TR>\n");
   $part=msqlFetchRow($sd);
   } 
   msqlFreeResult($sd);

   echo("</TABLE><BR>\n");
   $grupa=msqlFetchRow($fd);
   } 
msqlFreeResult($fd);
msqlClose($sock);


>

<INPUT TYPE="reset" VALUE="Clear fileds">
<INPUT TYPE="submit" VALUE="Submit data">

</FORM>
