andrej13 Posted March 9, 2011 Share Posted March 9, 2011 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 More sharing options...
Pikachu2000 Posted March 9, 2011 Share Posted March 9, 2011 You do have output. Look a the View--->Source of the page. Your logic for if(!isset($_POST['submit']) ) { is cratering things. Link to comment https://forums.phpfreaks.com/topic/230120-php-and-sql-no-output/#findComment-1185112 Share on other sites More sharing options...
andrej13 Posted March 9, 2011 Author Share Posted March 9, 2011 You do have output. Look a the View--->Source of the page. Your logic for if(!isset($_POST['submit']) ) { is cratering things. Thanks I know what you mean, but how can I solve this? thanks in advance Link to comment https://forums.phpfreaks.com/topic/230120-php-and-sql-no-output/#findComment-1185117 Share on other sites More sharing options...
andrej13 Posted March 9, 2011 Author Share Posted March 9, 2011 You do have output. Look a the View--->Source of the page. Your logic for if(!isset($_POST['submit']) ) { is cratering things. i did what you said, still nothing... did I forget an else {} somewhere? Link to comment https://forums.phpfreaks.com/topic/230120-php-and-sql-no-output/#findComment-1185200 Share on other sites More sharing options...
Pikachu2000 Posted March 9, 2011 Share Posted March 9, 2011 I don't know without you posting your current code. Link to comment https://forums.phpfreaks.com/topic/230120-php-and-sql-no-output/#findComment-1185202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.