Hey Guy's!
I have made a script and it seems to work (i am sure there is a way for it to be simplified). The one issue i am having with it, is it is printing out everything(even if a box is not ticked) or too many (about 3x what is needed) see this example
PHP Code:
INSERT INTO eggs(dateLaid,laidBy) VALUES ('2013-02-12','4'),('2013-02-12','4'),('2013-02-12','4'),('2013-02-12','4'),('2013-02-12','3'),('2013-02-12','3'),('2013-02-12','3'),('2013-02-12','3'),;
and here's the script.
any advice would be wonderful!
PHP Code:
$totalHens = post('henCount');
$henId = post("id");
$i = 0;
$date = post("date");
$laid = post("laid");
$query ="INSERT INTO eggs(dateLaid,laidBy) VALUES ";
foreach ($henId as $input ) {
foreach ($laid as $hasLaid => $value) {
if($value == 'laid'){
foreach ($date as $theDate => $dateLaid) {
$query .= "('{$dateLaid}','{$input}')";
if($i < $totalHens){
$query .= ",";
}
}
}
}
$i++;
}
$query .= ";";
return $query;
i had to do the foreach for laid, and date, or else it was not getting the correct data. As i said earler i am sure there is a way to make this cleaner. I just kind of hacked everything together
Bookmarks