RE: check box help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If I understand your question correctly, you really don't have to do much to
accomplish what you're looking to do. If you name your checkboxes as an
array ($myCheckboxes[]) then, when the form data is submitted, all of the
$myCheckboxes[] will be passed as an indexed array called, surprisingly
enough, $myCheckboxes ($myCheckboxes[0], $myCheckboxes[1], etc.). In the
resulting script, you need only iterate over them with a control structure
such as a for() loop.

Hope this helps.

-----Original Message-----
From: Matt [mailto:mpalermo@vt.edu]
Sent: Thursday, January 30, 2003 4:58 PM
To: php-db@lists.php.net
Subject:  check box help


Hey can anyone help me out?  I am a bit of an amatuer at this.  Here is my
problem:

I have an SQL table with a three fields in it.  They are ClassTitle,
InstructorName, and CourseDescription.  I am setting up a table that lists
the records with a check box in front of it.  Then if the user checks the
box, it will give him access to that data(which I have set up in a separate
table).  The problem is that I don't know how to name the check box, since
it goes through a while loop.  I want the user to be able to check more than
one box, if it is neccessary.  But I don't know how to name the check boxes
uniquely (one check box for each record in the table), so that once they are
checked, I can work with it later on the next page.  I have inserted a chunk
of the code I am working on for it.  Please help me if you can.  Thanks.

if (!mysql_connect($dbserver, $dbusername, $dbpassword)) {
        print 'Could not connect to mysql';
        exit;
    }

    $result = mysql_list_tables($dbname);

    if (!$result) {
        print "DB Error, could not list tables\n";
        print 'MySQL Error: ' . mysql_error();
        exit;
    }
    mysql_free_result($result);

$CourseInfo = mysql_query("SELECT * FROM $TableName");
while ($row=mysql_fetch_assoc($CourseInfo)) {
echo "<tr>
    <td width='3%' style='border-style: none; border-width: medium'>
    <input type='checkbox' name='$CourseCheck' value='ON'></td>
    <td width='7%' style='border-style: none; border-width: medium'>
    <p align='right'><b><font color='#800000'>Course:</font></b></td>
    <td width='18%' style='border-style: none; border-width: medium'
colspan='2'>
    <p align='center'><font color='#111111'>";
echo $row["ClassTitle"];
echo "</font></td>
    <td width='8%' style='border-style: none; border-width: medium'
colspan='2'>
    <b><font color='#800000'>Instructor:</font></b></td>
    <td width='15%' style='border-style: none; border-width: medium'>
    <p align='left'>";
echo $row["InstructorName"];
echo "</td>
    <td width='15%' style='border-style: none; border-width: medium'>
    <b><font color='#800000'>Course Description:</font></b></td>
    <td width='36%' style='border-style: none; border-width: medium'
colspan='2'>
    <p align='center'>";
echo $row["CourseDescription"];
echo "</td>
  </tr>
<tr>
<td width='100%' style='border-style: none; border-width: medium'
colspan='10'>
    &nbsp;</td>
</tr>
  <tr>";
}


Thanks,

Matt



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux