storeing php url variables as a php variable

Discussion in 'Web Design and Development' started by hansolo669, Feb 14, 2012.

  1. hansolo669 macrumors regular

    Oct 5, 2009
    i have searched around to no avail. essentially what i want to do is have the url variable (?1 ?234 ?2534753 what ever it is) store itself in a php variable which would then inject itself into an html image tag loading the image with the corresponding number (i.e "" would load "1.jpg" into the page)

    my code (for this part) as it stands looks like this
    <? if (!empty($_SERVER["QUERY_STRING"])) ?>
    <? $img_name = QUERY_STRING ?>
    <img src= "<? echo $img_name ?>" width="1024" height="768"/>
  2. Darth.Titan macrumors 68030


    Oct 31, 2007
    Austin, TX
    I believe the route I'd take would be more like:
    if (isset(
    $img_name $img_path $_GET['image'];
    $width$height$type$attr) = getimagesize($img_path.'image_name.jpg');
    <img src= "<?=$img_name?><?=$attr?> />
    (i.e "" would load "1.jpg" into the page)

    Of course that would need to be tweaked depending on your image directory location.

Share This Page