include("bd.php");
$res = mysql_query("SELECT * FROM `film` ");
while($row = mysql_fetch_array($res))
{
echo $row['idfilm'];
echo "<br>";
echo $row['name'];
echo "<br>"
echo $row['reyting'];
/* добавляете параметр data-rating, значением этого параметра id записи в базе данных */
echo '<div class="plus" data-rating="' . $row['idfilm'] . '">+</div>';
}
$('div.plus').on('click', function(){
var Id = $(this).attr('data-rating');
$.ajax({
url: 'shablon/film_plus.php',
type: 'POST',
data: Id,
success: function(data){
/* тут обрабатываете ответ сервера */
}
})
})
ALTER TABLE `comments`
ADD CONSTRAINT `fk_comments_images` FOREIGN KEY (`image_id`) REFERENCES `comments` (`id`) ON DELETE CASCADE;
SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE `comments`
ADD CONSTRAINT `fk_comments_images` FOREIGN KEY (`image_id`) REFERENCES `comments` (`id`) ON DELETE CASCADE;
SET FOREIGN_KEY_CHECKS=1;
foreach ($items as $product) {
$item = new OrderItem();
$item->order_id = $model->id;
$item->item_id = $product->getProductId();
$item->quantity = $product->getQuantity();
$item->item_price = $product->getCost();
if(!$item->save()){
var_dump($item->errors);
die;
}
}
<?= Html::a('<i class="glyphicon glyphicon-trash text-danger"></i>', ['/order/default/delete-order', 'id' => $order->id], [
'data-toggle' => 'tooltip',
'data-placement' => 'bottom',
'title' => 'Удалить заказ из корзины',
'data' => [
'confirm' => 'Вы уверены?',
'data-method' => 'get',
'delete-url' => Url::to('/order/default/delete-order');
],
]) ?>
$('form').on('beforeSubmit', function(){
var data = $(this).serialize();
var url = $(selector).attr('data-delete-url');
$.ajax({
url: url,
type: 'POST',
data: data,
success: function(response){
$('#basket').html(response);
},
error: function(){
alert('Error!');
}
});
return false;
});
<?= $form->field($model, 'typeRequest')->dropDownList([],['class' => 'class_name']) ?>
//указываете пространство имён
use components\GoogleAuthenticator;
//используете
$ga = new GoogleAuthenticator;
'buttons' => [
'add' => function ($url, $model, $key)
{
if($model->category_id == 0){
return Html::a('<span class="glyphicon glyphicon-plus"></span>', $url);
}
},
]
$unzip = new ZipArchive();
if($unzip->open($file[0]->tempName) === true){
for ($i = 0; $i < $unzip->numFiles; $i++){
$filename = $unzip->getNameIndex($i);
$fileinfo = pathinfo($filename);
$new_title = Yii::$app->security->generateRandomString();
if(copy('zip://' . $file[0]->tempName . '#' . $filename, Yii::getAlias('@webroot') . '/' . $path . '/' . $new_title . '.' . $fileinfo['extension'])){
$this->saveImage($path, $new_title . '.' . $fileinfo['extension'], $this->id);
}
}
$unzip->close();
return true;
}
else{
return false;
}
'fieldConfig' => ['options' => ['tag' => false]]
.