Ik wil het totaal aantal records in de DB tellen, en die waarde opnemen als getal.
Maar op onderstaande manier wil het niet lukken.
Kan iemand mij vertellen hoe ik die waarde er wel in krijg.
Ook krijg ik deze foutmelding te zien, waar ik dus niets van snap.
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /customers/7/1/d/thetimberwolves.nl/httpd.www/site/biggame.php:1) in /customers/7/1/d/thetimberwolves.nl/httpd.www/site/biggame.php on line 10
<?php
/**
* @author Ben Janssen
* @copyright 2012
*/
ini_set('display_errors',1);
error_reporting(E_ALL);
session_start();
//Include
include'../cfg/cfg.php';
mysql_select_db($db,$con);
# sql debug
define('DEBUG_MODE',true); // true == aan, false == uit
# functie voor sql debug
function showSQLError($sql,$error,$text='Error')
{
if (DEBUG_MODE)
{
return '<pre>Error: ' . $error . '<br />' . $sql . '</pre>';
}
else
{
return $text;
}
}
$sql = "SELECT COUNT(*) FROM reservation WHERE speeldatum='2012-10-07'";
if (($result = mysql_query($sql)) === false)
{
echo showSQLError($sql,mysql_error(),'Fout met database.');
}
else
{
$row = mysql_fetch_row($result,$con);
}
if($row == 100)
{
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link type="text/css" rel="stylesheet" href="../css/content.css"/>
<title>TTW • Big game</title>
</head>
<body>
<p>Het is helaas niet meer mogelijk om te reserveren.</p>
<p>Voor meer info, neem contact op met de beheerder.</p>
<p></p>
</body>
</html>
';
}
else
{
$row2 = 100 - $row;
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link type="text/css" rel="stylesheet" href="../css/content.css"/>
<title>TTW • Big game</title>
</head>
<body>
<p style="text-align:center">Er zijn nog '.$row2.' plaatsen van de 100 beschikbaar.</p>
<form action="../biggame.php" name="biggame" id="BG1" method="post">
<table style="margin-left:auto;margin-right:auto">
<tr><td style="text-align:left">Naam</td><td>:</td><td style="text-align:left"><input class="mssg2" type="text" name="naam" id="BG2"/></td></tr>
<tr><td style="text-align:left">Achternaam</td><td>:</td><td style="text-align:left"><input class="mssg2" type="text" name="anaam" id="BG3"/></td></tr>
<tr><td style="text-align:left">Team naam</td><td>:</td><td style="text-align:left"><input class="mssg2" type="text" name="team" id="BG4"/></td></tr>
<tr><td style="text-align:left">Email</td><td>:</td><td style="text-align:left"><input class="mssg2" type="text" name="email" id="BG5"/></td></tr>
<tr><td style="text-align:left">Aantal dozen</td><td>:</td><td style="text-align:left">
<select id="BG6" name="dozen">
<option selected="selected" value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<select id="BG7" name="paint">
<option selected="selected" value="Shield">Shield</option>
<option value="Claymore">Claymore</option>
<option value="Mace">Mace</option>
</select>
</td></tr>
<tr><td colspan="3">
<img id="captcha" src="/securimage/securimage_show.php" alt="CAPTCHA Image"/>
</td></tr>
<tr><td colspan="3">
<input type="text" name="captcha_code" size="10" maxlength="6"/>
<a href="#" onclick="document.getElementById(\'captcha\').src = \'/securimage/securimage_show.php?\' + Math.random(); return false">[ Different Image ]</a></td></tr>
<tr><td style="text-align:center" colspan="3">
<input class="but" type="reset" id="butn_4" value="Reset"/>
<input class="but" type="submit" id="butn_5" value="Verzenden"/>
</td></tr>
</table>
</form>
</body>
</html>
';
}
?>
1.728 views