I need to insert data from below inputs to database. Whole <div class="clone">
can be cloned with jquery and it also adds +1 to names, for example next created div will have inputs named name="npm[]1", name="apm[]1" etc. <div class="list" id="sub">
part list subcategories of shops that can be checked (shop can have multiple subcategories) and they also get +1 on names. Is it ok like that?
<div class="clone">
<label>Shop name</label><input type="text" name="npm[]0" id="npm" required>
<label>Address</label><input type="text" name="apm[]0" id="apm" required>
<label>City</label><input type="text" name="mipm[]0" id="mipm" required>
<label>Working hours</label><input type="text" name="rv[]0" id="rv" required>
<label>Tel</label><input type="text" name="ktf[]0" id="ktf" required>
<label>Mob</label><input type="text" name="ktm[]0" id="ktm" required>
<label>E-mail</label><input type="text" name="kea[]0" id="kea" required>
<label>Contact person</label><input type="text" name="ipko[]0" id="ipko" required>
<a id="select" class="ctpct">Select shop subcategory</a>
<div class="list" id="sub">
<?php
$a="select a.id,a.cat,b.x,b.subcat,b.cat_id from cat a
inner join
subcat b
on a.id = b.cat_id
where b.cat_id !=1
order by a.id";
$res = mysql_query($a) or die(mysql_error());
$cat = '';
while ($re = mysql_fetch_array($res))
{
if( $cat === '' )
{
$cat = $re["cat"];
echo "<div class='catdis'>";
echo "<h2>$cat</h2>";
}
elseif( $cat !== $re["cat"] )
{
$cat = $re["cat"];
echo "</div>";
echo "<div class='catdis'>";
echo "<h2>$cat</h2>";
}
$subcat= $re["subcat"];
$id= $re["x"];
echo "<input type='checkbox' name='subcat[]0' value='$id'> $subcat<br />";
}
?>
</div>
</div>
PHP part:
foreach ($_POST as $key => $value) {
$values = mysql_real_escape_string($value);
$query2 = "INSERT INTO shops(n, a, c, wh, tel, mob, mail, con) VALUES ('$values')";
$rs2=mysql_query($query2) or die(mysql_error());
}
Now, php part that i have prints this "Column count doesn't match value count at row 1", it may be because under that clone div i have few more inputs, normal ones.
I'am php newbie so can you please help me with this. I need it to insert data for every shop from input 'Shop name' to 'Contact person' in table 'shops' and selected subcategories in table 'shop_subcat' with subcategory_id and shop_id
Thank you!