Languages :: PHP :: How to enlarge thumbnail image by using links (w/o query strings) |
|||
| By: jwnrb |
Date: 25/09/2003 00:00:00 |
Points: 95 | Status: Answered Quality : Excellent |
|
Hi, Currently, I have two images on my projects page, but I will later add more projects so I want an easy way of doing this task. I dont have imagemagick on my server, just netpbm. though i dont think thats as clever as it can be. the URI is <A HREF="http://www.jwnrb.com/projects.php">http://www.jwnrb.com/projects.php</a> and the code that does it is as follows: <?php if ($_GET[large] != "1"){ echo "<img src=\"downloads/preview_tweak_sm.png\" alt=\"Preview TweakXP\" />"; echo "[<a href=\"projects.php?large=1\">ENLARGE</a>]</a><br />"; } elseif($_GET[large] == "1"){ echo "<img src=\"downloads/preview_tweak.png\" alt=\"Preview TweakXP\" />"; echo "[<a href=\"projects.php\">SHRINK</a>]</a><br />"; } ?> |
|||
| By: VGR | Date: 25/09/2003 04:27:00 | Type : Comment |
|
| <?php $isbig=($_GET[large] == "1"); $link=($isbig)?"'>ENLARGE":"?large=1'>SHRINK"; echo "<img src='downloads/preview_tweak".(($isbig)?'':'_sm').".png' alt='Preview TweakXP'>"; echo "[<a href='projects.php$link</a>]<br />"; ?> |
|||
| By: jwnrb | Date: 25/09/2003 17:02:00 | Type : Comment |
|
| well that makes the coding of what i did a little prettier, but i dont want to use query strings at all. i want internal variables that WONT be shown on the URI |
|||
| By: VGR | Date: 25/09/2003 17:29:00 | Type : Answer |
|
| ok <?php $isbig=($_GET['large'] == "1"); // NEVER EVER USE ASSOCIATIVE ARRAYS WITHOUT QUOTES !!! See PHP doc ! $link=($isbig)?"":'?large=1'; $thesm=(($isbig)?'':'_sm'); echo <<<EOS <form name=main action=project.php$link method=POST> <input type=hidden name=image value=preview_tweak.png><!--just an example--> <input type=hidden name=isbig value={$_GET['large']}><!--just an other example--> </form> <script language=javascript> function go() { document.forms.main.submit(); } </script> <img src='downloads/preview_tweak$thesm.png' alt='Preview TweakXP'>[<input type=button value="preview" onClick="go();">]<br /> EOS; ?> happy ? :D |
|||
| By: jwnrb | Date: 25/09/2003 18:03:00 | Type : Comment |
|
| guess i'm happy now ;-) |
|||
| By: VGR | Date: 25/09/2003 18:18:00 | Type : Comment |
|
| then gimme the points ;-) |
|||
| By: jwnrb | Date: 26/09/2003 01:09:00 | Type : Comment |
|
| Ooops thought I did ;-) |
|||
| By: VGR | Date: 26/09/2003 02:50:00 | Type : Comment |
|
| thanks, but beware, things are becoming tricky when you use buttons onClick="some javascript" which has to recover form's data and submit() it's really spaghetti coding IMHO |
|||
| By: jwnrb | Date: 26/09/2003 03:26:00 | Type : Comment |
|
| actually, i liked your revising of my code better so i think i would use that instead. i dont like query strings bc the variables are in the URI. when i get more projects i like for enlarging to be done on all screenshots that can be available, plus eventually im going to translate my page in multiple languages as well. so projects.php?lang=en&proj=3 might be a tad annoying. though i can have a sysnopsis on the top, and i can only make a seperate one as well later on. hmm..... and maybe sessions/or cookies so i can have multiple enlarged at the same time. sorry for rambling, it gets my ideas out so i can remember them later ;-) |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








