Эй, ребята, я пытаюсь вставить некоторые флажки в базу данных, и я почти уверен, что мой код верен, однако я продолжаю получать сообщение об ошибке ERROR INSERTING: Column count doesn't match value count at row 1
В основном я добавляю каждый флажок в отдельный столбец в моембаза данных
Вот мой код
$idextra=$_POST['extras'];
$arr_num=count($idextra);
$i=0;
while ($i < $arr_num)
{
$qu="INSERT INTO bs_reservations (deodoriser,carpet,carpetrepair,furniture,tabs,urine) VALUES ('$idextra[$i]')";
$res=mysql_query($qu) or die('ERROR INSERTING: '.mysql_error());
$i++;
}
Эй, ребята, вот HTML-код для моих флажков и контактной формы.
`
<tr>
<td height="30" align="right" class="align_right">Your Name*: </td>
<td>
<input type="text" name="name" id="name" value="<?php echo $name?>" onchange="checkFieldBack(this)"/>
</td>
</tr>
<tr>
<td height="30" align="right" class="align_right">Phone*: </td>
<td><input type="text" name="phone" id="phone" value="<?php echo $phone?>" onchange="checkFieldBack(this)" onkeyup="noAlpha(this)"/></td>
</tr>
<tr>
<td height="30" align="right" class="align_right">E-mail*: </td>
<td><input type="text" name="email" id="email" value="<?php echo $email?>" onchange="checkFieldBack(this);"/></td>
</tr>
<tr>
<td align="right" valign="top" class="align_right">Address*: </td>
<td><textarea name="comments" id="comments" cols="15" rows="5" onchange="checkFieldBack(this)"><?php echo $comments?></textarea></td>
</tr>
<tr>
<td width="236" height="25" align="left">Drop off at:</td>
<td width="548" height="23"><select name="dropoff">
<option value="05:00" <?php echo $dropoff=="05:00"?"selected":""?>>05:00</option>
<option value="06:00" <?php echo $dropoff=="06:00"?"selected":""?>>06:00</option>
<option value="07:00" <?php echo $dropoff=="07:00"?"selected":""?>>07:00</option>
<option value="08:00" <?php echo $dropoff=="08:00"?"selected":""?>>08:00</option>
<option value="09:00" <?php echo $dropoff=="09:00"?"selected":""?>>09:00</option>
<option value="10:00" <?php echo $dropoff=="10:00"?"selected":""?>>10:00</option>
<option value="11:00" <?php echo $dropoff=="11:00"?"selected":""?>>11:00</option>
<option value="12:00" <?php echo $dropoff=="12:00"?"selected":""?>>12:00</option>
<option value="13:00" <?php echo $dropoff=="13:00"?"selected":""?>>13:00</option>
<option value="14:00" <?php echo $dropoff=="14:00"?"selected":""?>>14:00</option>
<option value="15:00" <?php echo $dropoff=="15:00"?"selected":""?>>15:00</option>
<option value="16:00" <?php echo $dropoff=="16:00"?"selected":""?>>16:00</option>
<option value="17:00" <?php echo $dropoff=="17:00"?"selected":""?>>17:00</option>
<option value="18:00" <?php echo $dropoff=="18:00"?"selected":""?>>18:00</option>
<option value="19:00" <?php echo $dropoff=="19:00"?"selected":""?>>19:00</option>
</select>
</td>
<tr>
<td height="10" align="right" class="align_right">Deodoriser: </td>
<td>
<input type="checkbox" name="extras[]" id="deodoriser" value="Deodoriser>"/>
</td>
</tr>
<tr>
<td height="30" align="right" class="align_right">Carpet Protector (5 litre): </td>
<td>
<input type="checkbox" name="extras[]" id="carpet" value="Carpet Protector (5 litre)"/>
</td>
</tr>
<tr>
<td height="30" align="right" class="align_right">Carpet Repair Tools: </td>
<td>
<input type="checkbox" name="extras[]" id="carpetrepair" value="Carpet Repair Tools"/>
</td>
</tr>
<tr>
<td height="30" align="right" class="align_right">Furniture Moving Equipment: </td>
<td>
<input type="checkbox" name="extras[]" id="furniture" value="Furniture Moving Equipment"/>
</td>
</tr>
<tr>
<td height="30" align="right" class="align_right">Furniture Tabs: </td>
<td>
<input type="checkbox" name="extras[]" id="tabs" value="Furniture Tabs"/>
</td>
</tr>
<tr>
<td height="30" align="right" class="align_right">Urine Decontamination Treatment: </td>
<td>
<input type="checkbox" name="extras[]" id="urine" value="Urine Decontamination Treatment"/>
</td>
</tr>
`
и вот мой полный код php для вставки в базу данных
` $ idextra = $ _ POST[ 'Extras'];$ Arr_num = счетчик ($ idextra);$ I = 0;while ($ i <$ arr_num) {</p>
$qu="INSERT INTO bs_reservations (deodoriser,carpet,carpetrepair,furniture,tabs,urine) VALUES ('{$idextra[1]}','{$idextra[2]}','{$idextra[3]}','{$idextra[4]}','{$idextra[5]}','{$idextra[6]}')";
$res=mysql_query($qu) or die('ERROR INSERTING: '.mysql_error());
$i++;
}
$q="INSERT INTO bs_reservations (dateCreated, name, email, phone, comments,status,eventID, qty,dropoff) VALUES (NOW(),'".$name."','".$email."','".$phone."','".$comments."','2','".$eventID."','".$qty."','".$dropoff."')";
$res=mysql_query($q) or die("error!");
$orderID=mysql_insert_id();`
В основном я хочу взять все входные данные, выбранные пользователем, и вставить их в базу данных.