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!
<?
//var to hold list location (substitute your own file name and text file)
$your_file = "photolink.txt";
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");
//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));
//array of file contents
$your_array = explode("\n",$contents_your_file);
//close the file
fclose($read_your_file);
//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;
//elements in the drop down list
//$drop_elmnts = 0;
//begin creating your dropdown menu...
$your_menu = "<select name=\"you_make_a_name\">";
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_variable\">$your_array[$counter]
</option>";
$counter++;
}
//end select menu
$your_menu .= "</select>";
?>
<html>
<head>
<title>Edit Photos</title>
</head>
<body>
<p><b>Photos</b><br>
<? echo "$your_menu"; ?>
</body>
</html>
And what I have in the text file are lines of urls to photos, ie http://www.website.com/pic.jpg, and what I am trying to figure out is how to get the photo I have selected in the drop list to display. any help would be great.
I just typed this up really quick and didn't test it but I think it will illustrate the idea and how to make it AJAXY. Basically you use javascript to make the selection work, I think my code in the onselct is wrong but it's close check w3schools.com for it, the rest should be straight.
<form>
Select text: <input type="text" value="Hello world!"
onselect="alert('You have selected some of the text.')">
<br /><br />
Select text: <textarea cols="20" rows="5"
onselect="alert('You have selected some of the text.')">
Hello world!</textarea>
</form>
but that is a built in function i guess. And you are making a new one? not sure how it all works but it seems like you are using it correctly but it doesnt work. I get this error
(Parse error: syntax error, unexpected T_STRING in /home/dp411net/public_html/phphotos/getlist.php)
That error happens right were I add your new code to my code. Sorry for being so noobish.