Answer the question
In order to leave comments, you need to log in
Doesn't query which package, what's the problem?
Hello, I can't figure out where I'm wrong... The code is created but doesn't get the package id from the "packages" table
<?php
if(isset($_POST['createnewCard']))
{
$plan = $_POST['plan'];
$errors = array();
if(empty($plan))
{
$errors[] = 'Такого тарифного плана не существует!';
}
if(empty($errors))
{
/// Генератор кода
$code = substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, 10);
/// Вход в базу данных
$SQLinsert = $odb -> prepare("INSERT INTO `giftcards` VALUES(NULL, :code, :planID, 0, 0, UNIX_TIMESTAMP())");
$SQLinsert -> execute(array(':code' => $code, ':planID' => $plan));
echo $design->alert('success', 'Success', 'Создана новая подарочная карта. Code: '.$code.'');
} else {
echo '<div class="alert alert-danger alert-dismissable">Ошибка!</br>';
foreach($errors as $error){
echo ' - '.$error.'';
}
echo ' </div>';
}
}
?>
<select class="form-control" name="plan[]">
<?php
$GetPackages = $odb -> query("SELECT * FROM `packages`");
while($getInfo = $GetPackages -> fetch(PDO::FETCH_ASSOC))
{
$ID = $getInfo['ID'];
$name = $getInfo['name'];
echo '<option value="'.$ID.'">'.$name.'</option>';
}
?>
</select>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question