PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
hi. I'm using a small function I built. It always worked. Now it does not, I tried to test if all the variable work and they do. but the if statement does not seem to work. here is the code:-
function look_pic01() {
$filename = "../../beginpagina.html";
$fp = fopen($filename, "r") or die("Could'nt open $filename");
$g_pic01 = "";
$i = 0;
// get from line 20 picture name and store it in $g_pic01
while (!feof($fp)) {
$i++;
$line = fgets($fp, 1024);
if ($i === 20) {$g_pic01 = $line;}
}
$path = "../../pictures/";
echo "<select name=\"pic01\">";
echo "<option value=\"\"></option>";
foreach(glob($path.'*.jpg') as $e) {
$check_pic01 = basename($e);
$sel_pic01 = "";
if ($g_pic01 === $check_pic01) {$sel_pic01 = "selected=\"selected\"";}
echo "<option value=\"".$check_pic01."\" ".$sel_pic01.">".$check_pic01." ".$sel_pic01."</option>\n";
}
echo "</select>";
}
what the function does is list all the pictures into a drop down menu. what what it does not work is the variable $sel_pic01 which stores the value selected="selected" if the picture name from html file and picture name from foreach loop matches in the if statement. Can anyone please help me? i really tried my best. thanks in advance
if (trim($g_pic01) === $check_pic01) {$sel_pic01 = "selected=\"selected\"";}
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.