Dears,
I have a problem with my php code.. What I am trying to do is to use the array data in a second mysql query to list the available options.
Explanation:
$conn = mysqli_connect($dbhost,$dbuser,$dbpass) or sqlerror();
mysqli_select_db($conn,$dbname);
$sql = mysqli_query($conn,"SELECT * FROM ADMIN WHERE id='".$_SESSION["adminusername"]."'");
$isadmin=mysqli_fetch_array($sql);
$arraydata= $isadmin["Files"];
mysqli_close($conn);
$array3 = explode(',',$arraydata);
Now, The code above give me: $arraydata = "26,27,28,29"
I used $array3 to remove the comma .. then tried foreach as following code should be executed:
$conn = mysqli_connect($dbhost,$dbuser,$dbpass) or sqlerror();
mysqli_select_db($conn,$dbname);
foreach ($array3 as $singleID) {
$sql=mysqli_query($conn,"SELECT FileID,FileTitle FROM Servers WHERE
FileType='CFG' AND FileID='".$singleID."'");
if(mysqli_num_rows($sql)){
$select= '<select class="smallInput" name="serverfile" tabindex="6">';
while($rs=mysqli_fetch_array($sql)){
$select.='<option value="'.$rs['FileID'].'">'.$rs['FileTitle'].'</option>';
}
}
$select.='</select>';
echo $select;
}
I was hopping this will show a select options for the items in Array that the condition in the second mysql query match, if array item found show it in the options of select ..
Anyone can fix this?