02-02-2010, 03:17 AM
|
#5 (permalink)
|
|
The Acquainted
Join Date: Apr 2008
Posts: 110
Thanks: 97
|
Thanks again. I've reworked my script and have posted it below. The problem is that after some rows are selected by checkboxes and the submit button is clicked, the $_POST array is empty, using print_r($_POST) to check.
Any suggestions? -- Dave
PHP Code:
<?php
session_start () ;
?>
<h1>Data Browse - Edit - Export</h1>
<?php
$host = 'localhost' ;
$root = 'root' ;
$db_pass = 'password' ;
$db = 'proj_sap' ;
$tb_data = 't_tims0809' ;
$schcode = "320" . $_SESSION [ 'school_code' ] ;
$sql = "
SELECT '' AS selection
, last_name AS lastname
, first_name AS firstname
, grade AS gr
, ethnic AS eth
, sex AS sex
, student_id AS sid
, reason AS reas
, mon_init AS month
FROM {$tb_data}
WHERE tag <> '' AND
tag IS NOT NULL AND
schcode = {$schcode}
LIMIT 1
" ;
?>
<!-- FORM -->
<form name = 'form1'
method = 'post'
action = '<?php echo $_SERVER["PHP_SELF"] ; ?>'>
<?php
echo "<h2>School: " . $schcode . "</h2>" ;
echo "<h2>Category: " . "current students" . "</h2>" ;
echo "<hr>" ;
$db = "proj_sap";
$db_user = "root";
$pass = "teacher";
$host = "localhost";
mysql_connect ( $host, $db_user, $pass )
|| exit ( "problem: " . mysql_error () ) ;
mysql_select_db ( $db )
|| exit ( "cannot connect to DB: " . mysql_error() ) ;
$qResult = mysql_query ( $sql ) ;
mysql_close();
if ( mysql_num_rows ( $qResult ) == 0 )
{
exit ( "no rows returned" ) ;
}
else
{
$fields_num = mysql_num_fields ( $qResult ) ;
$nRowCount = mysql_num_rows ( $qResult ) ;
}
$output = "<table width = \"100%\"
valign = \"center\"
border = \"1\"
cellpadding = \"1\"
cellspacing = \"1\" >" ;
$output .= "<tr>" ;
for ( $i = 0 ; $i < $fields_num ; $i++ )
{
$oField = mysql_fetch_field ( $qResult, $i ) ;
$output .= "<th> {$oField->name} </th>" ;
}
$output .= "</tr>\n";
while ( $aRecords = mysql_fetch_array ( $qResult ) )
{
$output .= "<tr><td>" ;
$output .= "<input type = 'checkbox'
name = 'checkbox[]'
id = '<?php echo $aRecords[sid] ; ?>'
value = '' " ;
$output .= "</td>" ;
for ( $n = 1 ; $n <= ( $fields_num - 1 ) ; $n++ )
{
$output .= "<td>" ;
$output .= $aRecords [ $n ] ;
$output .= "</td>" ;
}
$output .= $aRecords [ $n ] ;
$output .= "</td>\n";
$output .= "</tr>\n" ;
} // End while
$output .= "</table>\n";
echo $output ;
?>
<!-- submit button here -->
<br /> <br />
<input type = "submit"
value = "Select Students" />
</form>
</body>
</html>
|
|
|
|