//The php section of the code
<?php
function getJSONFromDB($sql){
$conn = mysqli_connect("localhost", "root", "","rent");
//echo $sql;
$result = mysqli_query($conn, $sql)or die(mysqli_error());
$arr=array();
while($row = mysqli_fetch_assoc($result)) {
$arr[]=$row;
}
return json_encode($arr);
}
$jsonData= getJSONFromDB("select Pic from Display");
$jsn=json_decode($jsonData);
//for loop to retrieve rows from database
for($i=0;$i<sizeof($jsn);$i++){
$a=$jsn[$i]->Pic;
//here is the main problem
echo "<html><body><img src='sponsor/$a.jpeg' alt=''></body></html>";
//here is the problem i am facing
}
?>
01
//The php section of the code
02
<?php
03
function getJSONFromDB($sql){
04
$conn = mysqli_connect("localhost", "root", "","rent");
05
//echo $sql;
06
$result = mysqli_query($conn, $sql)or die(mysqli_error());
07
$arr=array();
08
while($row = mysqli_fetch_assoc($result)) {
09
$arr[]=$row;
10
}
11
return json_encode($arr);
12
}
13
$jsonData= getJSONFromDB("select Pic from Display");
14
$jsn=json_decode($jsonData);
15
//for loop to retrieve rows from database
16
for($i=0;$i<sizeof($jsn);$i++){
17
$a=$jsn[$i]->Pic;
18
//here is the main problem
19
echo "<html><body><img src='sponsor/$a.jpeg' alt=''></body></html>";
20
//here is the problem i am facing
21
22
}
23
?>
24
Mohammed_44 0 Newbie Poster
network18 15 Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.