Jump to content

Recommended Posts

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">&nbsp;</td>
    </tr>
    <tr>
      <td class="dettagli">DOB: ######</td>
    </tr>
    <tr>
      <td class="dettagli">Sire  : &nbsp;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
Link to comment
https://forums.phpfreaks.com/topic/9482-very-simple-question/
Share on other sites

[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]
Link to comment
https://forums.phpfreaks.com/topic/9482-very-simple-question/#findComment-34971
Share on other sites

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>
Link to comment
https://forums.phpfreaks.com/topic/9482-very-simple-question/#findComment-34984
Share on other sites

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">&nbsp;</td>
    </tr>
    <tr>
      <td class="dettagli">Data di Nascita : 09/05/1999</td>
    </tr>
    <tr>
      <td class="dettagli">Padre  : &nbsp;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">&nbsp;</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">&nbsp;</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">&nbsp;</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&deg; Eccellente, migliore di razza <br />
2&deg; ATIBOX Giovani Portogallo nel 2000<br />
2&deg; 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\" /]
Link to comment
https://forums.phpfreaks.com/topic/9482-very-simple-question/#findComment-35004
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/9482-very-simple-question/#findComment-35005
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/9482-very-simple-question/#findComment-35013
Share on other sites

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">&nbsp;</td>
    </tr>
    <tr>
      <td class="dettagli">Data di Nascita : 09/05/1999</td>
    </tr>
    <tr>
      <td class="dettagli">Padre  : &nbsp;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">&nbsp;</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">&nbsp;</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">&nbsp;</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&deg; Eccellente, migliore di razza <br />
2&deg; ATIBOX Giovani Portogallo nel 2000<br />
2&deg; 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>&nbsp; </p>
    <p></p>
</div>

<? } include("footer.php") ?>
[/code]

in the header.php file there's the layout :)
Link to comment
https://forums.phpfreaks.com/topic/9482-very-simple-question/#findComment-35019
Share on other sites

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 !!!
Link to comment
https://forums.phpfreaks.com/topic/9482-very-simple-question/#findComment-35021
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.