Home quering data from a table are missing
Reply: 0

quering data from a table are missing

user1326
1#
user1326 Published in April 22, 2018, 5:57 pm
$items = '';
$sql = "select items from bplus where pos = 'home-01' limit 1";
$st = $db->query($sql);
$res = $st->fetchColumn();
$arr = explode("\n", $res);
foreach ($arr as $el){
//echo $el . "<br>"; // as a test - it's ok - four images.      
$sqlb = "select * from banners where fname = '" . $el . "'";
    $stb = $db->query($sqlb);
    $row = $stb->fetch();
    $items .= "<img class='itemtop' src = '../banners/" . $el . "' alt='img' data-id = " . $row['id'] . " data-fname = '" . $row['fname'] . "' data-w = " . $row['width'] . " data-h = " . $row['height'] . ">\n"; 
}
echo $items;

final result:

<img class='itemtop' src = '../banners/5ad461206f52e.jpg
' alt='img' data-id =  data-fname = '' data-w =  data-h = >
<img class='itemtop' src = '../banners/5ad461206f916.jpg
' alt='img' data-id =  data-fname = '' data-w =  data-h = >
<img class='itemtop' src = '../banners/5ad461206fcff.jpg
' alt='img' data-id =  data-fname = '' data-w =  data-h = >
<img class='itemtop' src = '../banners/5ad461207d7c2.jpg' alt='img' data-id = 29 data-fname = '5ad461207d7c2.jpg' data-w = 320 data-h = 50>

Why are the first three images without any data?
In the table all images has its data.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.35251 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO