Question: Creating String array and linking $variable to specific string
Hey guys,
I have a website at http://www.wrcc.dri.edu/monitor/WWDT/index.php and I am trying to associate the $folder PHP variable with a string (text) so that I can display this nicely above and below the image chosen by the user. [right click and view source to see what I am talkin' about]
For example, if users choose SPI 2 Month, $folder=spi2 and I want a string associated with that (lets says $fstring) to be 'SPI 2 Month' ... How do I create an array and link it to the $folder chosen?
Thanks so much,
Hope I asked my question properly and made it easy on you guys to answer.
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
Ahhh but I mean on that page where do you see an example of the $_GET function that you used. I wouldnt have known to use the $_GET within the $legend var... I am a nub.
Still not working Fire.... code is below for you to check out:
PHP Code:
<?php $exp=time()+86400; $dir='images'; $img='png'; $cl='_cl'; setcookie ("dirC",$dir,$exp); setcookie ("clC",$cl,$exp); setcookie ("imgC",$img,$exp); // Use value from URL and update cookie with new value if (isset($_GET['region'])) { $region = $_GET['region']; setcookie('regionC', $region, $exp); // Else, use cookie value if available } elseif (isset($_COOKIE['regionC'])) { $region = $_COOKIE['regionC']; // Finally, no cookie and no URL value so use default } else { $region = 'ww'; setcookie('regionC', $region, $exp); }
// Use value from URL and update cookie with new value if (isset($_GET['ds'])) { $ds = $_GET['ds']; setcookie('dsC', $ds, $exp); } elseif (isset($_COOKIE['dsC'])) { $ds = $_COOKIE['dsC']; } else { $ds = 'PRISM'; setcookie('dsC', $ds, $exp); }
<?php $dir='images'; echo "<h3> Path: $ds > $legends_var[$_GET['folder']] > $legends_region[$_GET['region']]</h3>"; //echo "<h3>Currently viewing images using the <u>$ds</u> dataset.</h3>"; //sets the folder string name if it was set previously if(isset($_GET['folder'])) $folder = $_GET['folder']; //sets the product string name if it was set previously //if(isset($_GET['product'])) $product = $_GET['product']; //if(isset($_GET['region'])) $region=$_GET['region']; //sets the region string name if it was set previously, if not then 'us' is used by default $img='png';$cl='_cl';$current='_current';$underscore='_'; if (file_exists("$dir/$folder/$region$cl.$img")) { if ($region=='us') { echo "<!--Displaying image from /$dir/$folder/$region.$img<br>--> <br><img src='$dir/$folder/$region.$img'> <br><br> <a class=\"hvr\" href=\"/monitor/WWDT/data/PRISM/$folder/$folder$current$underscore$ds.nc\"><u>Download $ds $legends_var[$_GET['folder']] NETCDF Data for United States</u></a> <br> <br> <a class=\"hvr\" href=\"/monitor/WWDT/data/PRISM/$folder/$folder$current$underscore$ds.tif\"><u>Download $ds $legends_var[$_GET['folder']] NETCDF Data for United States</u></a>"; } else { echo "<!--Displaying image from /$dir/$folder/$region$cl.$img<br>--> <br><img src='$dir/$folder/$region$cl.$img'> <br><br> <a class=\"hvr\" href=\"/monitor/WWDT/data/PRISM/$folder/$folder$current$underscore$ds.nc\"><u>Download $ds $legends_var[$_GET['folder']] NETCDF Data for United States</u></a> <br> <br> <a class=\"hvr\" href=\"/monitor/WWDT/data/PRISM/$folder/$folder$current$underscore$ds.tif\"><u>Download $ds $legends_var[$_GET['folder']] GeoTIFF Data for United States</u></a>"; } } else { echo "<h4>File image requested within the $ds dataset is not available</h4><br>"; } ?>
your url has ?folder=whatever , that should therefore be present in $_GET['folder'] automagically.
I think its just the way you are echoing out ...
try replacing
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
I am trying to save it into memory (cookies now) but no luck... Its not saving legreg and legvar the way I want it to... upon cookies cleared it should by default have $legreg="Western US" and $legvar="Palmer Drought Severity Index"
Check out the code :
PHP Code:
<?php $exp=time()+86400; $dir='images'; $img='png'; $cl='_cl'; setcookie ("dirC",$dir,$exp); setcookie ("clC",$cl,$exp); setcookie ("imgC",$img,$exp); // Use value from URL and update cookie with new value if (isset($_GET['region'])) { $region = $_GET['region']; setcookie('regionC', $region, $exp); // Else, use cookie value if available } elseif (isset($_COOKIE['regionC'])) { $region = $_COOKIE['regionC']; // Finally, no cookie and no URL value so use default } else { $region = 'ww'; setcookie('regionC', $region, $exp); }
// Use value from URL and update cookie with new value if (isset($_GET['ds'])) { $ds = $_GET['ds']; setcookie('dsC', $ds, $exp); } elseif (isset($_COOKIE['dsC'])) { $ds = $_COOKIE['dsC']; } else { $ds = 'PRISM'; setcookie('dsC', $ds, $exp); }
<?php $dir='images'; $legvar=$legends_var[$_GET['folder']]; $legreg=$legends_region[$_GET['region']]; echo "<h3> Current Product: $ds > " . $legvar . " > " . $legreg . "</h3>"; //echo "<h3>Currently viewing images using the <u>$ds</u> dataset.</h3>"; //sets the folder string name if it was set previously if(isset($_GET['folder'])) $folder = $_GET['folder']; //sets the product string name if it was set previously //if(isset($_GET['product'])) $product = $_GET['product']; //if(isset($_GET['region'])) $region=$_GET['region']; //sets the region string name if it was set previously, if not then 'us' is used by default $img='png';$cl='_cl';$current='_current';$underscore='_'; if (file_exists("$dir/$folder/$region$cl.$img")) { if ($region=='us') { echo "<!--Displaying image from /$dir/$folder/$region.$img<br>--> <br><img src='$dir/$folder/$region.$img'> <br><br> <a class=\"hvr\" href=\"/monitor/WWDT/data/PRISM/$folder/$folder$current$underscore$ds.nc\"><u>Download $ds " . $legvar . " NETCDF Data for United States</u></a> <br> <br> <a class=\"hvr\" href=\"/monitor/WWDT/data/PRISM/$folder/$folder$current$underscore$ds.tif\"><u>Download $ds " . $legvar . " NETCDF Data for United States</u></a>"; } else { echo "<!--Displaying image from /$dir/$folder/$region$cl.$img<br>--> <br><img src='$dir/$folder/$region$cl.$img'> <br><br> <a class=\"hvr\" href=\"/monitor/WWDT/data/PRISM/$folder/$folder$current$underscore$ds.nc\"><u>Download $ds " . $legvar . " NETCDF Data for United States</u></a> <br> <br> <a class=\"hvr\" href=\"/monitor/WWDT/data/PRISM/$folder/$folder$current$underscore$ds.tif\"><u>Download $ds " . $legvar . " GeoTIFF Data for United States</u></a>"; } } else { echo "<h4>File image requested within the $ds dataset is not available</h4><br>"; } ?>