Jump to content


Photo

Very simple question


  • Please log in to reply
13 replies to this topic

#1 Antonella

Antonella
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationItaly

Posted 10 May 2006 - 04:56 PM

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:


<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>

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

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 10 May 2006 - 05:10 PM

<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>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 Antonella

Antonella
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationItaly

Posted 10 May 2006 - 05:37 PM

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=auto:0]<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>

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 10 May 2006 - 05:56 PM

Can you post your full/updated code again? What Crayon Violent posted should work.

Info: PHP Manual


#5 Antonella

Antonella
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationItaly

Posted 10 May 2006 - 06:01 PM

Here it is :)

<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>

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\" /]

#6 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 10 May 2006 - 06:04 PM

2 things:

1) change:
<img src="immagini/allevamento/<?= $image; ?>" alt="Gunther dei Roeri" width="310" height="260" />
to (note short-tag change):
<img src="immagini/allevamento/<?=$image?>" alt="Gunther dei Roeri" width="310" height="260" />

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.

Info: PHP Manual


#7 Antonella

Antonella
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationItaly

Posted 10 May 2006 - 06:08 PM

I've changed what you told me to, but everything's the same and the links to the images still result in blank pages :S

Thenks for your patience!

#8 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 10 May 2006 - 06:18 PM

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.

Info: PHP Manual


#9 Antonella

Antonella
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationItaly

Posted 10 May 2006 - 06:27 PM

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:

<? 
//
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") ?>

in the header.php file there's the layout :)

#10 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 10 May 2006 - 06:31 PM

Umm... what's this?
<? if(!$_SERVER['QUERY_STRING']) { ?>

That's going to stop it from loading the page if you have anything in the $_REQUEST array.

Info: PHP Manual


#11 Antonella

Antonella
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationItaly

Posted 10 May 2006 - 06:38 PM

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 !!!

#12 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 10 May 2006 - 06:41 PM

You should be able to nest switches no problem.

Info: PHP Manual


#13 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 10 May 2006 - 06:43 PM

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.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#14 Antonella

Antonella
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationItaly

Posted 10 May 2006 - 06:48 PM

thanks for letting me know!

I'll try and fix it :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users