Jump to content

chung09

New Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by chung09

  1. Sorry, I'm new to forum. ><

    there are 3 checkbox actually, i would like to display different result when different checkbox are selected.

    the value of checkbox is get from the previous page.

     

    the rule is:

    IF checkbox=1 THEN result=1

    IF checkbox=2 THEN result=2

    IF checkbox=3 THEN result=3

    IF checkbox=1 AND checkbox=2 THEN result=4

    IF checkbox=1 AND checkbox=3 THEN result=5

     

    IF checkbox=2 AND checkbox=3 THEN result=6

    IF checkbox=1 AND checkbox=2 AND checkbox=3 THEN result=7

     

    how will the code look like when i want a combination ? im keep trying but i can't solve it.

    Can you please teach me? thank you

  2. Can anybody help me to check what's wrong with the coding.
    First, i get the value of checkbox from the previous page.
    So, if checkbox 1 and 2 is selected, result with result_id 4 will be shown.
    if checkbox 1 and 3 is selected, result with result_id 5 will be shown.

    Now the problem is...no matter which checkbox is selected, the program will only run 'if statement' ,
    which is result_id 4.
    Below is the coding.
    Hope you guys can help me. >< .Thank alot!!

    <?php
    session_start();
    if(isset($_GET['checkbox'])){
    $checkbox = $_GET['checkbox'];
    }

    else {
    header('Location:tutorial.php');
    }

    include("database.php");

    for($i=0; $i < count($checkbox); $i++){
    {
    if ($checkbox[$i]= '1' && $checkbox[$i]= '2'){
    $sql="SELECT * FROM result WHERE result.result_id = 4";}

    elseif ($checkbox[$i]='1' && $checkbox[$i]= '3'){
    $sql="SELECT * FROM result WHERE result.result_id = 5";}

    else {}

    }
    }

    $result=mysql_query($sql); 

    echo "<form action = 'result.php' method='POST'> 
    <br/>";
    echo "<table>";
    while($row = mysql_fetch_array($result))
    {
    $result_name=$row['result_name'];
    $result_id=$row['result_id'];
    $result_desc=$row['result_desc'];
    $image=$row['image'];

    echo "<h4>$result_name</h4> ";

    echo "<tr >";
    echo "<td>";
    echo "</form>";?>
    <img src="<?php echo $row ["image"];?>" width="500" height = "600" align="left" border="1" /><?php echo "</td>" ;


    echo "</tr>";
    }
    echo "</table>";

    ?>

     

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