I have a PHP page with 3 dropdownlists on it. Everytime with an ‘onchange’ event a javascript docs get’s the selected value’s and transfers it to a php function, where I can transfer them to my mysql-database and get results out of them. This thing works perfect, but not when I apply my logic to define which function I should call
My php page contains the effective logic (see code-box) and underneed there are the 2functions with the actions. The function do work, but the problem is this. There’s the possibility in the if-else construction that the functions can be called on 2 different moments. The first time in the if-else construction both of the calls are succesfull and the result is what it should be, the second moments it seems that the $result parameter is empty?
$result = mysql_query($sql) or die("Query failed with error: ".mysql_error());
$aantal = mysql_num_rows($result);
if($amount == 0){
echo "<p>This combination does not exist</p>";
}
else {
// lists are empty
if($soort == 'Empty' && $land == 'Empty' && $jaar == 'Empty'){
}
else {
if ($aantal > 2){
maketable($aantal, $result); // -> **succesfull call**
}
else if($aantal == 1){
makedetails($result); // -> **succesfull call**
}
else {
$first = mysql_result($result, 0);
$second = mysql_result($result, 1);
if (($second - $first) == 1){
makedetails($result); // -> **does not work**
}
else {
maketable($aantal, $result); // -> **does not work**
}
}
}
}
function maketable($aantal, $result) { … }
function makedetails($result){ … }
greetings
Had to fetch my result once more to make it possible to loop through my array once again.
But thanks for the help!
greetings