Say there are two items in the $_POST['dobyyyy'] array... this is what my code will do..
PHP Code:
$dtdob['0'] = $_POST['dobyyyy']['0']. "-" .$_POST['dobmm']['0']. "-" .$_POST['dobdd']['0'];
$dtdob['1'] = $_POST['dobyyyy']['1']. "-" .$_POST['dobmm']['1']. "-" .$_POST['dobdd']['1'];
Here's an example of a script I have doing the same thing, almost.
PHP Code:
<?php
function hanks($c) {
for ($i = 0; $i < strlen($c); $i++) {
if ($c[$i] == "h") { $c[$i] = 1; }
if ($c[$i] == "a") { $c[$i] = 2; }
if ($c[$i] == "n") { $c[$i] = 3; }
if ($c[$i] == "k") { $c[$i] = 4; }
if ($c[$i] == "s") { $c[$i] = 5; }
if ($c[$i] == "p") { $c[$i] = 6; }
if ($c[$i] == "r") { $c[$i] = 7; }
if ($c[$i] == "i") { $c[$i] = 8; }
if ($c[$i] == "c") { $c[$i] = 9; }
if ($c[$i] == "e") { $c[$i] = 0; }
if ($c[$i] == "x") { $c[$i] = $c[($i-1)]; }
}
return $c;
}
for ($i = 0; $i < $_POST['rows']; $i++) {
$qty = $_POST['qtys'][$i];
$ven = $_POST['vendor'][$i];
$pid = $_POST['pid'][$i];
$des = $_POST['desc'][$i];
$cos = $_POST['cost'][$i];
if ($ven == "United") {
$cos = hanks($cos);
}
$pri = $_POST['price'][$i];
$cos = sprintf("%1.2f", ($cos/100));
if ($qty != "") {
mysql_query("INSERT INTO inventory VALUES ('', '".$pid."', '".$des."', '".$qty."', '".$cos."', '".$pri."', '".$ven."')");
}
}
header("Location: index.php");
?>
and index.php form:
PHP Code:
<form method="post" action="save.php">
<?php
$rows = 25;
for ($i = 0; $i < $rows; $i++) {
echo "\n";
?>
<div class="invrow">
<input class="fqt" type="text" name="qtys[]">
<select class="fve" name="vendor[]">
<option>Blish</option>
<option>United</option>
<option>Orbit</option>
<option>Rainbird</option>
<option>CPI</option>
<option>National</option>
<option>Other</option>
</select>
<input class="fpi" type="text" name="pid[]">
<input class="fde" type="text" name="desc[]">
<input class="fco" type="text" name="cost[]">
<input class="fpr" type="text" name="price[]">
</div>
<?php
}
echo "\n";
?>
<input type="hidden" name="rows" value="<?=$rows;?>">
<input type="hidden" name="time" value="<?=date("h:i");?>">
<input type="submit" style="display: none;">
</form>
Bookmarks