kurt.santo Posted October 23, 2007 Share Posted October 23, 2007 Working on some matters under http://www.jalp.co.uk/imageSwap/picture.php I wondered if there is a way to automatically pass id=12 when the page is loaded. It would make my testing easier when I do not all the time have to click on nav bar to see the results and just works with a default value unless I click onto nav bar...Kurt Link to comment Share on other sites More sharing options...
justsomeguy Posted October 23, 2007 Share Posted October 23, 2007 $id = (isset($_GET['id']) ? $_GET['id'] : 12); Link to comment Share on other sites More sharing options...
kurt.santo Posted October 24, 2007 Author Share Posted October 24, 2007 $id = (isset($_GET['id']) ? $_GET['id'] : 12);I understand that it tests if the id is set and if yes, updates the value. If no, it set value to default=12. This is exactly what I am after. But where do I put this line? Tried it in head and body, but does not work... The file name is set as "<IMG src="thumbs/1-<?php echo $_GET['id']; ?>.gif">".Kurt Link to comment Share on other sites More sharing options...
Synook Posted October 24, 2007 Share Posted October 24, 2007 Put it right at the top, and change that <img /> tag to read <img src="thumbs/1-<?php echo $id; ?>.gif" /> Link to comment Share on other sites More sharing options...
kurt.santo Posted October 24, 2007 Author Share Posted October 24, 2007 Put it right at the top, and change that <img /> tag to read<img src="thumbs/1-<?php echo $id; ?>.gif" /> I put it above the doc type declaration, which seems wrong. Instead of doing what it should do it shows the code above all other content?Kurt Link to comment Share on other sites More sharing options...
justsomeguy Posted October 24, 2007 Share Posted October 24, 2007 All PHP code needs to go inside PHP tags. Link to comment Share on other sites More sharing options...
kurt.santo Posted October 24, 2007 Author Share Posted October 24, 2007 All PHP code needs to go inside PHP tags.Got it now, works perfectly! Is it ok to place it before doc type or where would you place "$id = (isset($_GET['id']) ? $_GET['id'] : 12);"? Does it matter at all?Kurt Link to comment Share on other sites More sharing options...
justsomeguy Posted October 24, 2007 Share Posted October 24, 2007 It doesn't matter as long as the variable gets set before you try to use it. Link to comment Share on other sites More sharing options...
kurt.santo Posted October 25, 2007 Author Share Posted October 25, 2007 It doesn't matter as long as the variable gets set before you try to use it.Cheers, mate...Kurt Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.