Jump to content

Php and Sql 'no output'


andrej13

Recommended Posts

I don't have any output after I push the button :s I dont know how

http://fhcs.be/index3.php

<?php
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/global.inc.php');
// Include functions

session_start();
?>
<?php if (!isset($_POST['submit'])) { ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

        <form method="post" action="<?php echo $PHP_SELF; ?>">
        <input type="submit" value="Toon Output" name="submit"/>
         

<?php
$dranken=array()   ;
$DrinkResult=mysql_query("SELECT name,price FROM products")or die(mysql_error());

      while($DrinkRow=mysql_fetch_assoc($DrinkResult)){
         $dranken[] = $DrinkRow;

      }
echo "<table>";

    foreach ($dranken as $DrinkRow) {
$optionlist = "<select name='{$DrinkRow['name']}_aantal'>";
for  ($i=0;$i<10;++$i) {
	$optionlist .= "<option value='$i'>$i</option>";
}
$optionlist .= "</select>";
echo "<tr><td>".$DrinkRow['name']." ".$DrinkRow['price']."</td>\n";
echo "<td>$optionlist</td></tr>\n";
}
echo "</table>";
?>
      

    </form>

    <?php
    }
    
    
$dranken=array()   ;
$DrinkResult=mysql_query("SELECT name,price FROM products")or die(mysql_error());

      while($DrinkRow=mysql_fetch_assoc($DrinkResult)){
         $dranken[] = $DrinkRow;

      }
echo "<table>";
    

    $totaalPrijs = 0;

    foreach ($dranken as $DrinkRow) {
        $aantal = $_POST[$DrinkRow['name'] . "_aantal"];
        if ($aantal > 0) {
            $prijsperDrank = $aantal * $DrinkRow['price'];
            echo $DrinkRow['name'] . " : " . $aantal . " Prijs: " . $prijsperDrank . "</br>";
			$totaalPrijs=$totaalPrijs + $prijsperDrank; }
    
}
if($totaalPrijs>0){	   
    echo " totaal: " .$totaalPrijs;}
    ?>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/230120-php-and-sql-no-output/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.