25. juli 2008 - 18:03
Der er
11 kommentarer
Hjælp til beløb udskrivelse
Hej Eksperter, Jeg har en problem på min visordrer.php side. Jeg kan få den til at vise alle andre informationer end beløbet, som hvergang uanset hvad bare bliver skrevet som 0 kr. Her er min visordrer.php funktion: <? ob_start(); session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="../stylesheet.css"> </head> <body> <center> <? include("../connect.php"); sqlconnect(); ?><? if(!isset($_SESSION['admin'])) { include("login/admincheck.php"); } else { echo "<br /><table style='border: 1px solid #cccccc;' cellspacing='0' cellpadding='8'>"; echo " <tr>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>ID</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Ordrenr.</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Navn</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Firma</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Adresse</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Adresse 2</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Postnr.</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>By</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>E-mail</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Telefon</b></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Mobil</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Kvittering</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>Beløb</b></font></td>"; echo " <td style='background-color: #3D9CD6; border-bottom: 1px solid #cccccc; '><font color='FFFFFF'><b>SLET</b></font></td>"; echo " </tr>"; $select_ordrer = mysql_query("SELECT * FROM testordrer") or die(mysql_error()); $number_ordrer = mysql_num_rows($select_ordrer); if($number_ordrer < 1) { echo ""; } else { while($row = mysql_fetch_array($select_ordrer)) { $belob = $row['beloeb'] / 100; echo " <tr>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['id'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['ordrenr'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['navn'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['firma'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['adresse'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['adresse2'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['postnr'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['by'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['email'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['telefon'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $row['mobil'] . "</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '><a target='_blank' href='vis_kvittering.php?id=" . $row['id'] . "'>Vis Kvittering</a></td>"; echo " <td style='border-bottom: 1px solid #cccccc; '>" . $belob . " kr.</td>"; echo " <td style='border-bottom: 1px solid #cccccc; '><a href='slet_ordre.php?id=" . $row['id'] . "'>x</a></td>"; echo " </tr>"; } } echo "</table>"; } ?>
Annonceindlæg fra Infor
tror så at problemet ligger i denne fil måske ?! : Betaling.php <font size='2' color='#3d9bd6'><b>»</b></font> </span> <span class='overskrift'>Betaling</span><br /><br /> <? $Error = 0; Unset($_SESSION['fejl']); If ($_REQUEST['navn'] == "") { $_SESSION['fejl'][] = "Feltet 'Navn' må ikke stå tomt<br /><br />"; $Error += 1; } If ($_REQUEST['adresse'] == "") { $_SESSION['fejl'][] = "Feltet 'Adresse' må ikke stå tomt<br /><br />"; $Error += 1; } If ($_REQUEST['postnr'] == "" || !is_numeric($_REQUEST['postnr'])) { $_SESSION['fejl'][] = "Feltet 'Postnr.' må ikke stå tomt og må kun indeholde tal<br /><br />"; $Error += 1; } If ($_REQUEST['by'] == "") { $_SESSION['fejl'][] = "Feltet 'By' må ikke stå tomt<br /><br />"; $Error += 1; } If ($_REQUEST['email'] == "") { $_SESSION['fejl'][] = "Feltet 'E-mail' må ikke stå tomt og skal indeholde et @ (Eks. Test@test.dk)<br /><br />"; $Error += 1; } If ($_REQUEST['telefon'] == "" || !is_numeric($_REQUEST['postnr'])) { $_SESSION['fejl'][] = "Feltet 'Telefon' må ikke stå tomt og må kun indeholde tal<br /><br />"; $Error += 1; } If ($Error != 0) { header("location:index.php?side=kassen"); } $kvittering = "<table cellspacing='0' cellpadding='10'>"; $kvittering = $kvittering . " <tr>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #cccccc;'><b>Varenr.</b></td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #cccccc;'><b>Beskrivelse</b></td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #cccccc;'><b>Størrelse</b></td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #cccccc;'><b>Pris</b></td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #cccccc;'><b>Antal</b></td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #cccccc;'><b>Pris i alt</b></td>"; $kvittering = $kvittering . " </tr>"; foreach($_SESSION['kurv'] as $value) { $sel = mysql_query("SELECT * FROM produkter WHERE id='$value[0]' LIMIT 1") or die(mysql_error()); if(mysql_num_rows($sel) == 1){ $row = mysql_fetch_array($sel); $kvittering = $kvittering . " <tr>"; $kvittering = $kvittering . " <td>" .$row['id']. "</td>"; $kvittering = $kvittering . " <td>" .$row['produkt']. "</td>"; $kvittering = $kvittering . " <td>" .$value[3]. "</td>"; $kvittering = $kvittering . " <td>" .$row['pris']. ",00 kr.</td>"; $kvittering = $kvittering . " <td>" .$value[1]. " stk.</td>"; $kvittering = $kvittering . " <td>" .$value[2]. ",00 kr.</td>"; $kvittering = $kvittering . " </tr>"; $KvitteringWin32 .= $row['id'] . ", " . $row['produkt'] . ", " . $value[3] . ", " . $row['pris'] . ",00 DKK, " . $value[1] . " stk., i alt " . $value[2] . ",00 DKK\r\n\r\n"; $totalPrisKvit += $value[2]; } } $totalPrisKvit += 30; $kvittering = $kvittering . " <tr>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #CCCCCC'><b>Fragt:</b></td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #CCCCCC'> </td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #CCCCCC'> </td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #CCCCCC'> </td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #CCCCCC'> </td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px solid #CCCCCC;'>30,00 kr.</td>"; $kvittering = $kvittering . " </tr>"; $kvittering = $kvittering . " <tr>"; $kvittering = $kvittering . " <td><b>Total: </b></td>"; $kvittering = $kvittering . " <td></td>"; $kvittering = $kvittering . " <td></td>"; $kvittering = $kvittering . " <td></td>"; $kvittering = $kvittering . " <td></td>"; $kvittering = $kvittering . " <td style='border-bottom: 1px double #CCCCCC; border-bottom-style: double;'><b>" .$totalPrisKvit. ",00 kr.</b></td>"; $kvittering = $kvittering . " </tr>"; $kvittering = $kvittering . "</table>"; $KvitteringWin32 .= "--------------------------------------------------------------------------------\r\n\r\n"; $KvitteringWin32 .= "Fragt: 30,00 DKK\r\n\r\n"; $KvitteringWin32 .= "--------------------------------------------------------------------------------\r\n\r\n"; $KvitteringWin32 .= "\r\n\r\nTotal pris: " . $totalPrisKvit . ",00 DKK"; If ($_SESSION['kurv']) { foreach($_SESSION['kurv'] as $value) { $totalPris += $value[2]; } $totalPris += 30; $totalPris = $totalPris * 100; } srand(time()); $random = (rand()%99999); $ordernumber = $random; $_SESSION['AdresseOplysninger'] = Array( 'kvittering' => $kvittering, 'totalPris' => $totalPris, 'ordernumber' => $ordernumber, 'firma' => $_REQUEST['firma'], 'navn' => $_REQUEST['navn'], 'adresse' => $_REQUEST['adresse'], 'adresse2' => $_REQUEST['adresse2'], 'postnr' => $_REQUEST['postnr'], 'by' => $_REQUEST['by'], 'email' => $_REQUEST['email'], 'telefon' => $_REQUEST['telefon'], 'mobil' => $_REQUEST['mobil'], 'kvitteringWin32' => $KvitteringWin32); $query_insert = mysql_query("INSERT INTO testordrer (ordrenr, firma, navn, adresse, adresse2, postnr, `by`, email, telefon, mobil, kvittering, beloeb) VALUES ('" . $_SESSION['AdresseOplysninger'][ordernumber] . "', '" . $_SESSION['AdresseOplysninger'][firma] . "', '" . $_SESSION['AdresseOplysninger'][navn] . "', '" . $_SESSION['AdresseOplysninger'][adresse] . "', '" . $_SESSION['AdresseOplysninger'][adresse2] . "', '" . $_SESSION['AdresseOplysninger'][postnr] . "', '" . $_SESSION['AdresseOplysninger'][by] . "', '" . $_SESSION['AdresseOplysninger'][email] . "', '" . $_SESSION['AdresseOplysninger'][telefon] . "', '" . $_SESSION['AdresseOplysninger'][mobil] . "', '" . str_replace("'", "`", $_SESSION['AdresseOplysninger'][kvittering]) . "', '" . $_SESSION['AdresseOplysninger'][totalpris] . "')") or die(mysql_error()); $ordernumber = mysql_insert_id(); ?> <FORM NAME="Betaling" ACTION="" METHOD="POST" TARGET="_TOP" AUTOCOMPLETE="OFF"> <!--<input type="hidden" name="Testtransaction" value="D"> <input type="hidden" name="Merchant" value="">--> <input type="hidden" name="Merchant" value=""> <INPUT TYPE="HIDDEN" NAME="Amount" VALUE="<? echo $totalPris ?>"> <INPUT TYPE="HIDDEN" NAME="Currency" VALUE="208"> <INPUT TYPE="HIDDEN" NAME="Accept" VALUE=""> <INPUT TYPE="HIDDEN" NAME="Decline" VALUE=""> <INPUT TYPE="HIDDEN" NAME="Ordernumber" VALUE="<? echo $ordernumber ?>"> <INPUT TYPE="HIDDEN" NAME="Emailresponse" VALUE=""> <!--<INPUT TYPE="HIDDEN" NAME="Emailresponse" VALUE="">--> Kortnummer:<br /> <INPUT TYPE="Text" NAME="Cardnumber" SIZE="19" /> <br /><br /> Udløbsdato (mm/åå):<br /> <INPUT TYPE="Text" NAME="Expmm" SIZE="2" /> <INPUT TYPE="Text" NAME="Expyy" SIZE="2" /> <br /><br /> Kontrolcifre:<br /> <INPUT TYPE="Text" NAME="CVC" SIZE="3" /> <br /><br /> <INPUT TYPE="Reset"><INPUT TYPE="SUBMIT" VALUE="Fortsæt"> </FORM> <? ?>
Så skulle fejlen vel ligge heromkring: If ($_SESSION['kurv']) { foreach($_SESSION['kurv'] as $value) { $totalPris += $value[2]; } $totalPris += 30; $totalPris = $totalPris * 100; } Din kode prøver i hvert fald fint at gemme beløbet, men hvis nu f.eks. din $_SESSION['kurv'] er tom.. Du kan dog prøve denne kode i stedet for den bid, jeg skrev ovenover: If ($_SESSION['kurv']) { $totalPris = $totalPrisKvit; foreach($_SESSION['kurv'] as $value) { $totalPris += $value[2]; } $totalPris += 30; $totalPris = $totalPris * 100; } Jeg har nemlig en mistanke om, at det er variablen $totalPrisKvit, som skulle bruges.