MySQL zoek query filter op waarde maar geen alle meta_value terug
Jop B
03/06/2020 22:42:08Quote:
Of je regelt dit gewoon ergens anders?
hij kan natuurlijk ook de waardes terug sturen en de zichtbaarheid regelen met JavaScript.
Of heb je nog een andere manier Thomas?
PHP hulp
23/12/2024 19:34:18Bryan De Baar
03/06/2020 22:42:10Je bedoeld zo Thomas
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
while($row = mysqli_fetch_assoc($result)){
if (false === isset($data[$row['ID']])) {
$ms_on = false;
$data[$row['ID']] = array(
'id' => $row['ID'],
'post_title' => $row['post_title'],
'price' => '-',
'stock' => '0',
);
}
if ($row['meta_key'] == '_price' && $row['meta_value'] !== '') {
$data[$row['ID']]['price'] = $row['meta_value'];
}
if ($row['meta_key'] == '_stock' && $row['meta_value'] !== '') {
$stock = $row['meta_value'];
}
if ($row['meta_key'] == '_manage_stock' && $row['meta_value'] == 'yes') {
$ms_on = true;
}
if($ms_on){
$data[$row['ID']]['stock'] = $stock;
}
}
?>
while($row = mysqli_fetch_assoc($result)){
if (false === isset($data[$row['ID']])) {
$ms_on = false;
$data[$row['ID']] = array(
'id' => $row['ID'],
'post_title' => $row['post_title'],
'price' => '-',
'stock' => '0',
);
}
if ($row['meta_key'] == '_price' && $row['meta_value'] !== '') {
$data[$row['ID']]['price'] = $row['meta_value'];
}
if ($row['meta_key'] == '_stock' && $row['meta_value'] !== '') {
$stock = $row['meta_value'];
}
if ($row['meta_key'] == '_manage_stock' && $row['meta_value'] == 'yes') {
$ms_on = true;
}
if($ms_on){
$data[$row['ID']]['stock'] = $stock;
}
}
?>