Re: Question regarding how-to stop the form inputting empty data at end of the form that is empty due to a carriage return

From: Date: Wed, 12 Jan 2005 06:24:55 +0000
Subject: Re: Question regarding how-to stop the form inputting empty data at end of the form that is empty due to a carriage return
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-38112@lists.php.net to get a copy of this message
В сообщении от Среда 12 Январь 2005 04:52 Mike Millner написал(a): > 243 Query INSERT INTO tape_tracking_test > (media_id,retention,out_date,return_date,box_id) values > > ('','7WK=%s','2005-01-11','2005-3-01','006455C5092800') > > > How can I get PHP to ignore that line that has empty data in the media_id > field? Hi. May be check $MediaID_ar[$i], and if it empty just not write media_id? f.e. $query = "INSERT INTO tape_tracking_test ("; if ( ! empty( $MediaID_ar[$i] ) ){ $query .= "media_id, "; } $query.= "retention,out_date,return_date,box_id) values ("; if ( ! empty( $MediaID_ar[$i] ) ){ $query .= "'".$MediaID_ar[$i]."',"; } $query.= '". $_POST['Retention'] ."=%s','". $_POST['OutDate'] ."','". $_POST['calendarDate'] ."','". $_POST['BoxID'] ."')"; mysql_query( $query ); bla bla bla

« previous php.db (#38112) next »