<?php
// Получение сплошного списка
function get_cat()
{
global $pdo;
$cat_arr = [];
try
{
$query = "SELECT ID, PID, NAME FROM `catalog` WHERE 1";
$stmt = $pdo->prepare( $query );
$stmt->execute();
}
catch (PDOException $e)
{
die("Error in :".__FILE__." file, at ".__LINE__." line. Can't get data : " . $e->getMessage());
}
while( $row = $stmt->fetch(PDO::FETCH_ASSOC ) )
$cat_arr[$row['ID']] = $row;
return $cat_arr;
}
// Построение дерева
function tree_map( $dataset )
{
$tree = [];
foreach ($dataset as $id=>&$node)
if (!$node['PID'])
$tree[$id] = &$node;
else
$dataset[$node['PID']]['childs'][$id] = &$node;
return $tree;
}
$dataset = get_cat();
$dataset = tree_map( $dataset );
<?php
function debug( $arr )
{
$str = print_r($arr, true);
echo '<pre>'.$str.'</pre>';
}
<?php
$id = []
$id[] = '1';
$id[] = '2';
$id[] = '3';
$id[] = '4';
$posts = R::findOne('posts', 'id', $id );
echo $posts->head, '<br>';
echo $posts->desc;
<?php
$posts = R::findOne('posts', 'id', [ '1', '2', '3', '4' ] );
или
$posts = R::findOne('posts', 'id', [ 1, 2, 3, 4 ] );
echo $posts->head, '<br>';
echo $posts->desc;
SELECT id,
(
SELECT items_info.PRICE FROM items
LEFT JOIN items_info ON items_info.id = items.item_id
WHERE items.id = JSON_EXTRACT(commission_items,'$[0]')
) AS price
FROM `bet_games`
WHERE 1
SELECT items_info.id, items_info.price FROM items
LEFT JOIN items_info ON items_info.id = items.item_id
WHERE
items.id IN
(
SELECT JSON_EXTRACT(`commission_items`,'$[0]')
FROM `bet_games`
)
<head>
<style>
body, select {
font-size: 12px;
}
form {
margin: 5px;
}
p {
color: red;
margin: 5px;
font-size: 14px;
}
b {
color: blue;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<form>
<select name="single">
<option>Single</option>
<option>Single2</option>
</select>
<br>
<select name="multiple" multiple="multiple">
<option selected="selected">Multiple</option>
<option>Multiple2</option>
<option selected="selected">Multiple3</option>
</select>
<br>
<input type="checkbox" name="check" value="check1" id="ch1">
<label for="ch1">check1</label>
<input type="checkbox" name="check" value="check2" checked="checked" id="ch2">
<label for="ch2">check2</label>
<br>
<input type="radio" name="radio" value="radio1" checked="checked" id="r1">
<label for="r1">radio1</label>
<input type="radio" name="radio" value="radio2" id="r2">
<label for="r2">radio2</label>
</form>
<p><tt id="results"></tt></p>
</body>
function showValues()
{
var str = $( "form" ).serialize();
$( "#results" ).text( str );
}
$( function()
{
$( "input[type='checkbox'], input[type='radio']" ).on( "click", showValues );
$( "select" ).on( "change", showValues );
showValues();
});
<div>Hello world</div>
div
{
position : absolute;
top : 200px;
left : 200px;
width : 100px;
background: lime;
}
$( function()
{
$('div').click(function(event){
alert('in div click')
event.stopPropagation();
});
$(window).click(function() {
alert('out of div click')
$('div').css('opacity', 0 )
});
});
...
stop: function( event, ui ) { alert(); div.data("stop")},
...
<div class='block'></div>
<a href='#' class='show-some'>1</a><br>
<a href='#' class='show-some'>2</a><br>
<a href='#' class='show-some'>3</a><br>
$(".show-some").click(function(){
var val = $( this ).text()
$.post('ajax.test.php',
{
val : val
},
function(data) {
$('.block').html(data);
});
});
<?php
$val = $_POST['val'];
echo $val ;