Antonella Posted May 10, 2006 Share Posted May 10, 2006 Hello everyone!I have a very simple question for you:how do I switch an image on a page while leaving everything else the same?I've tried this way, but it didn't work, I see the default page, but whenever I click on the links I get a blank page:[code]<table> <tr> <td> <h1>Gunther dei Roeri</h1></td> </tr> <tr> <td><? switch($_REQUEST['id']){default: ?> <img src="immagini/allevamento/ras2.jpg" alt="Gunther dei Roeri" width="310" height="260" /> <? break; case '1': ?> <img src="immagini/allevamento/ras2.jpg" alt="Gunther dei Roeri" width="310" height="260" /> <? break; case '2': ?> <img src="immagini/allevamento/ras5.jpg" alt="Gunther dei Roeri" width="310" height="260" /> <? break; case '3': ?> <img src="immagini/allevamento/ras3.jpg" alt="Gunther dei Roeri" width="310" height="260" /><? break; } ?> </td> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli">DOB: ######</td> </tr> <tr> <td class="dettagli">Sire : Ch. David del Colle dell'Infinito<br> Dam : Glenda dei Roeri</td> </tr>........</table>[/code]If you need to see the page: [a href=\"http://lnx.boxerdellabraidola.com/gunther.php\" target=\"_blank\"]it's here[/a](it's just a test, of course [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Thanks for any help Quote Link to comment Share on other sites More sharing options...
.josh Posted May 10, 2006 Share Posted May 10, 2006 [code]<table> <tr> <td> <h1>Gunther dei Roeri</h1></td> </tr> <tr> <td><? switch($_REQUEST['id']) { case '1': $image="ras2.jpg"; break; case '2': $image="ras5.jpg"; break; case '3': $image="ras3.jpg"; break; default: $image="ras2.jpg"; break; } <img src="immagini/allevamento/<?php echo $image; ?>" alt="Gunther dei Roeri" width="310" height="260" /> </td> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli">DOB: ######</td> </tr> <tr> <td class="dettagli">Sire : Ch. David del Colle dell'Infinito<br> Dam : Glenda dei Roeri</td> </tr>........</table>[/code] Quote Link to comment Share on other sites More sharing options...
Antonella Posted May 10, 2006 Author Share Posted May 10, 2006 it doesn't work [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] maybe my links are wrong? I've linked the images like this:[code]<td class="dettagli">Photos<a href="gunter.php?id=1">1</a> <a href="gunther.php?id=2">2</a> <a href="gunther.php?id=3">3 </a></td> Quote Link to comment Share on other sites More sharing options...
ober Posted May 10, 2006 Share Posted May 10, 2006 Can you post your full/updated code again? What Crayon Violent posted should work. Quote Link to comment Share on other sites More sharing options...
Antonella Posted May 10, 2006 Author Share Posted May 10, 2006 Here it is :)[code]<table> <tr> <td> <h1>Gunther dei Roeri</h1></td> </tr> <tr> <td><? switch($_REQUEST['id']) { case '1': $image="ras2.jpg"; break; case '2': $image="ras5.jpg"; break; case '3': $image="ras3.jpg"; break; default: $image="ras2.jpg"; break; } ?> <img src="immagini/allevamento/<?= $image; ?>" alt="Gunther dei Roeri" width="310" height="260" /> </td> </tr> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli">Data di Nascita : 09/05/1999</td> </tr> <tr> <td class="dettagli">Padre : Ch. David del Colle dell'Infinito<br> Madre : Glenda dei Roeri</td> </tr> <tr> <td class="dettagli">Allevatore : Allevamento dei Roeri </td> </tr> <tr> <td class="dettagli">Proprietario : Ruben Maschio</td> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli">Altre Foto <a href="gunter.php?id=1">1</a> <a href="gunther.php?id=2">2</a> <a href="gunther.php?id=3">3 </a></td> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli"><a href="m_pedigree.php?gunther" onClick="return popup(this, 'notes')">Pedigree</a></td> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli">HD 0<br> Esente da Spondilosi e Cardiopatie<br></td> </tr> <tr> <td class="dettagli">CAL3, IPO1, ZTP, selezionato a vita<br />A Bundesjugendsieger austriaco nel 2000<br />1° Eccellente, migliore di razza <br />2° ATIBOX Giovani Portogallo nel 2000<br />2° Campione Giovane Mondiali di Milano 2000<br />Campione Internazionale I.O. </td> </tr> <tr> <td><div align="center"><a href="m_pedigree.php?gunther" onClick="return popup(this, 'notes')"></a></div> <div align="center"><a href="gunther.php?foto">FOTO</a></div></td> </tr> </table>[/code]and [a href=\"http://lnx.boxerdellabraidola.com/gunther.php\" target=\"_blank\"]here's[/a] what happens.Probably I have written the requests for the images in a wrong way [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] Quote Link to comment Share on other sites More sharing options...
ober Posted May 10, 2006 Share Posted May 10, 2006 2 things:1) change:[code]<img src="immagini/allevamento/<?= $image; ?>" alt="Gunther dei Roeri" width="310" height="260" />[/code]to (note short-tag change):[code]<img src="immagini/allevamento/<?=$image?>" alt="Gunther dei Roeri" width="310" height="260" />[/code]And if that doesn't fix it, change $_REQUEST to $_GET in case you have a variable with "id" in a SESSION or something like that. Quote Link to comment Share on other sites More sharing options...
Antonella Posted May 10, 2006 Author Share Posted May 10, 2006 I've changed what you told me to, but everything's the same and the links to the images still result in blank pages :SThenks for your patience! Quote Link to comment Share on other sites More sharing options...
ober Posted May 10, 2006 Share Posted May 10, 2006 Here's the thing that confuses me. I could understand if it's not running the PHP, or you're getting some kind of error, but the weirdest thing is that you're not getting any errors, all the content around this is showing up, but NONE of what you're posting is showing up in the source.The details of the dog should at least be showing up, even if the picture doesn't.Can you post the code for the entire page? It's like you're forgetting to include something... or you have something else that is blocking out that entire chunk of code. Quote Link to comment Share on other sites More sharing options...
Antonella Posted May 10, 2006 Author Share Posted May 10, 2006 That's what confuses me too [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] I usually use switches in my sites and I've done some scripts, that thanks to phpfreaks forum work perfectly and now I can't seem to change an image on a page [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] btw, here's the complete page:[code]<? //include("header.php") ?><? if(!$_SERVER['QUERY_STRING']) { ?><div id="text" class="chroma"> <table> <tr> <td> <h1>Gunther dei Roeri</h1></td> </tr> <tr> <td><? switch($_GET['id']) { case '1': $image="ras2.jpg"; break; case '2': $image="ras5.jpg"; break; case '3': $image="ras3.jpg"; break; default: $image="ras2.jpg"; break; } ?> <img src="immagini/allevamento/<?=$image?>" alt="Gunther dei Roeri" width="310" height="260" /> </td> </tr> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli">Data di Nascita : 09/05/1999</td> </tr> <tr> <td class="dettagli">Padre : Ch. David del Colle dell'Infinito<br> Madre : Glenda dei Roeri</td> </tr> <tr> <td class="dettagli">Allevatore : Allevamento dei Roeri </td> </tr> <tr> <td class="dettagli">Proprietario : Ruben Maschio</td> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli">Altre Foto <a href="gunter.php?id=1">1</a> <a href="gunther.php?id=2">2</a> <a href="gunther.php?id=3">3 </a></td> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli"><a href="m_pedigree.php?gunther" onClick="return popup(this, 'notes')">Pedigree</a></td> </tr> <tr> <td class="dettagli"> </td> </tr> <tr> <td class="dettagli">HD 0<br> Esente da Spondilosi e Cardiopatie<br></td> </tr> <tr> <td class="dettagli">CAL3, IPO1, ZTP, selezionato a vita<br />A Bundesjugendsieger austriaco nel 2000<br />1° Eccellente, migliore di razza <br />2° ATIBOX Giovani Portogallo nel 2000<br />2° Campione Giovane Mondiali di Milano 2000<br />Campione Internazionale I.O. </td> </tr> <tr> <td><div align="center"><a href="m_pedigree.php?gunther" onClick="return popup(this, 'notes')"></a></div> <div align="center"><a href="gunther.php?foto">FOTO</a></div></td> </tr> </table> <p> </p> <p></p></div><? } include("footer.php") ?>[/code]in the header.php file there's the layout :) Quote Link to comment Share on other sites More sharing options...
ober Posted May 10, 2006 Share Posted May 10, 2006 Umm... what's this? [code]<? if(!$_SERVER['QUERY_STRING']) { ?>[/code]That's going to stop it from loading the page if you have anything in the $_REQUEST array. Quote Link to comment Share on other sites More sharing options...
Antonella Posted May 10, 2006 Author Share Posted May 10, 2006 ouch [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] !this remained from a previous version of the page (I had three different pages in the file that where called via a file.php?page type of query)Now it works perfectly [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]Anyway, it seems that I can't nest switches, can I?I mean, if I have more pages on a file and I also want to have a page where I change images like this, I can't ?Thanks again !!! Quote Link to comment Share on other sites More sharing options...
ober Posted May 10, 2006 Share Posted May 10, 2006 You should be able to nest switches no problem. Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted May 10, 2006 Share Posted May 10, 2006 glad that you figured it out. it works fine now :)you can nest switches.one side note: the content floats outside of the container in firefox. Quote Link to comment Share on other sites More sharing options...
Antonella Posted May 10, 2006 Author Share Posted May 10, 2006 thanks for letting me know!I'll try and fix it :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.