Вот полная форма:Почему значение даты не добавляется в БД?
$ (документ) .ready (функция() { $ ("#datepicker") .datepicker(); });
<div class="labelContainer">
<label for="Date">Date</label>
</div>
<div class="labelContainer">
<label for="Category">Category</label>
</div>
<div class="inputContainer">
<select name="category" id="category" value="category" class="form-control ddplaceholder" style="width:220px;font-size:18px;font-family:Roboto;">
<option value="" disabled selected>Select Category</option>
<?php
$sth = $conn->prepare('Select name From category');
$sth->execute();
$data = $sth->fetchAll();
foreach ($data as $row){
if($row['name']!="")
echo ' <option id=\"CategoryName\" nameCategoryNameVendorName\" value="' .$row['name']. '">'.$row['name'].'</option>';
}
?>
</select></div><br>
<br>
<div class="labelContainer">
<label for="Item">Item</label>
</div>
<div class="inputContainer">
<select name="item_name" id="item_name" value="item_name" class="form-control ddplaceholder" style="width:220px;font-size:18px;font-family:Roboto;">
<option value="" disabled selected>Select Item</option>
<?php
$sth = $conn->prepare('Select item_name From item');
$sth->execute();
$data = $sth->fetchAll();
foreach ($data as $row){
if($row['item_name']!="")
echo " <option id=\"ItemName\" name=\"ItemName\" value=".$row['item_name'].">".$row['item_name']."</option>";
}
?>
</select></div><br>
<div class="labelContainer">
<label for="Vendor">Vendor</label>
</div>
<div class="inputContainer">
<select name="vendor_name" id="vendor_name" value="vendor_name" class="form-control ddplaceholder" style="width:220px;font-size:18px;font-family:Roboto;">
<option value="" disabled selected>Select Vendor</option>
<?php
$sth = $conn->prepare('Select name From vendor');
$sth->execute();
$data = $sth->fetchAll();
foreach ($data as $row){
if($row['name']!="")
echo " <option id=\"VendorName\" name=\"VendorName\" value=".$row['name'].">".$row['name']."</option>";
}
?>
</select></div><br>
<div class="labelContainer">
<label for="Unit">Unit</label>
</div>
<div class="inputContainer">
<input type="text" placeholder="Unit" id="Unit" name="Unit" ><br>
</div>
<div class="labelContainer">
<label for="Price_per_Unit">Price_per_Unit</label>
</div>
<div class="inputContainer">
<input type="text" placeholder="Price per Unit" name="Price_per_Unit" id="Price_per_Unit"><br>
</div>
<div class="labelContainer">
<label for="Quantity">Quantity</label>
</div>
<div class="inputContainer">
<input type="text" placeholder="Quantity" name="Quantity" id="Quantity"><br>
</div>
<div class="labelContainer">
<label for="VAT">VAT</label>
</div>
<div class="inputContainer">
<input type="text" placeholder="VAT" name="VAT" id="VAT"><br>
</div>
<div class="labelContainer">
<label for="Freight_charges">Freight_charges</label>
</div>
<div class="inputContainer">
<input type="text" placeholder="Freight charges" id="Freight_charges" name="Freight_charges"><br>
</div>
<div class="labelContainer">
<label for="Other_Charges">Other_Charges</label>
</div>
<div class="inputContainer">
<input type="text" placeholder="Other Charges" id="Other_Charges" name="Other_Charges"><br>
</div>
<div class="labelContainer">
<label for="Total">Total</label>
</div>
<div class="inputContainer">
<input type="text" placeholder="Total" id="Total" name="Total"><br>
</div>
<input type="submit" name="submit" value="Update" style="width:150px;padding:10px;">
<?php
$date="";
$category_value="";
$item_value="";
$vendor_value="";
$unit_value="";
$price_rate_value=0;
$quantity_value=0;
$vat_value=0;
$freight_value=0;
$other_charges_value=0;
$total_value=0;
if(!empty($_POST['category']))
{
$category_value=$_POST['category'];
}
if(!empty($_POST['item_name']))
{
$item_value=$_POST['item_name'];
}
if(!empty($_POST['vendor_name']))
{
$vendor_value=$_POST['vendor_name'];
}
if(!empty($_POST['Unit']))
{
$unit_value=$_POST['Unit'];
}
if(!empty($_POST['Price_per_Unit']))
{
$price_rate_value=$_POST['Price_per_Unit'];
}
if(!empty($_POST['Quantity']))
{
$quantity_value=$_POST['Quantity'];
}
if(!empty($_POST['Freight_charges']))
{
$freight_value=$_POST['Freight_charges'];
}
if(!empty($_POST['Other_charges']))
{
$other_charges_value=$_POST['Other_charges'];
}
if(!empty($_POST['VAT']))
{
$vat_value=$_POST['VAT'];
}
$total_value= ($price_rate_value * $quantity_value)+$freight_value+$other_charges_value+$vat_value;
$sql='INSERT INTO bill(date, category, item, vendor, unit, price_per_unit, quantity, vat, freight_charges, other_charges, total) '
. 'values (:date,:category, :item,:vendor, :unit, :price_per_unit, :quantity, :vat, :freight_charges, :other_charges, :total)';
$sth=$conn->prepare($sql);
$sth->execute(array(':date'=>$date,':category'=>$category_value,':item'=>$item_value, ':vendor'=>$vendor_value,
':unit'=>$unit_value,':price_per_unit'=>$price_rate_value,':quantity'=>$quantity_value,':vat'=>$vat_value,
':freight_charges'=>$freight_value,':other_charges'=>$other_charges_value,':total'=>$total_value));
?>
</form>
Как я могу добавить дату? Уже пробовали, что сейчас говорят ответы. Это потому, что нет даты, связанной с датой? Может быть, из-за этого?
Я пробовал, но не работал. –
, пожалуйста, эхо ваш $ _POST ['datepicker']; значение и дайте мне знать результат @VineetBasantani – JYoThI
Я не получаю никакого результата. Я поместил эхо внутри 'if (! Empty ($ _ POST ['datepicker']) {}' И не получил результата. –