[Status: learner] Using checkboxes, the user selects rows from a displayed HTML table. I then want to insert the date and the unique row id ("select_id") of the selected ('ticked') rows into a different table. Maybe I'm off-base, but it seems to me that the first block of code does not work. The second block of code does work. If I'm correct, it appears that it matters where the $SQL statement is made. WHY? I mean, no variable assignments are made until the $sql is called by the mysql_query() function, right?
(... Yanılıyorsam, boşver, o evde sadece normal bir akşam.)
$sql = "INSERT INTO sap_id_select ( select_date
, select_id )
VALUES ( CURRENT_DATE ()
, '{$cSelected_id}' )
" ;
if ( isset ( $_POST [ checkbox] ) )
{
foreach ( $_POST [ checkbox ] as $cSelected_id )
{
mysql_query ( $sql ) or ( "Error: " . mysql_error () ) ;
}
}
================================
if ( isset ( $_POST [ checkbox] ) )
{
foreach ( $_POST [ checkbox ] as $cSelected_id )
{
$sql = "INSERT INTO sap_id_select ( select_date
, select_id )
VALUES ( CURRENT_DATE ()
, '{$cSelected_id}' )
" ;
mysql_query ( $sql ) or ( "Error: " . mysql_error () ) ;
}
}