0

hi guyz, i'm new to PHP and my first time to post here..
i would like to ask some help regarding CHECKBOXES..
..I'm havng problem on displaying the values of the checked checkboxes to other pages...how would i do that?

HERE IS MY CODE FOR THE FIRST PAGE:

<?php
                        $sql = "select * from tbl_services";
                        $query=@mysql_query($sql) or die("SQL Error");

                    while($row=@mysql_fetch_array($query))
                    {
                        $_i++; //increments the number in the tbl_services


                        echo "<tr >";
                            echo "<td>";
                                echo $row["ServiceCode"];
                            echo "</td>";
                            echo "<td>";
                                echo $row["ServiceName"];
                            echo "</td>";
                            echo "<td align='center'>";
                                echo "<input type='checkbox' name='check".$_i."' >";
                            echo "</td>";
                        echo "</tr >";
                    }
                    echo"<input type='hidden' name='ServiceID".$_i."' value='".$row["ServiceID"]."'>";
                    echo "<input type='hidden' names' value='".$_i."'>";
            ?>

MY CODE FOR THE ACTION PAGE:

<?php

    ob_start();
    require_once("header.php");

    $_count=$_GET["count"];
    $_service = $_POST["check"];

    for($_i=1;$_i<=$_count;$_i++)
    {
        $_check=$_GET["check".$_i];
        if($_check=="on")
        {
            $_ServiceID=$_GET["ServiceID".$_i];
            echo $_ServiceID;
        }
    }

?>

Edited by Dani: Formatting fixed

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by P0lT10n
0

Hello, first of all NEVER call a variable $_NAME NEVER, do $NAME... Modify this and post again your code but between CODE-tags.

And i found an error here

echo"<input type='hidden' name='ServiceID".$_i."' value='".$row["ServiceID"]."'>";

Do this

echo "<input type='hidden' name='ServiceID".$i."' value='".$row['ServiceID']."'>";

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.