It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

How do you say this in PHP?

Moderator: Malcolm

How do you say this in PHP?

Postby duckboy1981 on Fri Sep 19, 2008 2:04 pm

Hi all,

I am a complete PHP novice but I have been told by another person on a different forum that the answer to my problem is to change the following code to it's PHP equivelent. The 'img/Marketing/Summer Drinks/SummerDrinks2008_01' needs to be one variable and the bit that says 'The Orangry' needs to be another. If any body is able to help it would be greatly appriciated.

Thanks,
David

Code: Select all
<div class="gallery">
<div class="thumb">
  <a href="javascript:DisplayImage('img/Marketing/Summer Drinks/SummerDrinks2008_01.jpg','300','225','The Orangry')">
                     <img src="img/Marketing/Summer Drinks/SummerDrinks2008_01.jpg" alt="The Orangry" width="149" height="112"
                     onmouseover="window.status='Summer Drinks 2008 - The Orangry';return true"
                     onmouseout="window.status='';return true">
                     <span><img src="img/Marketing/Summer Drinks/SummerDrinks2008_01.jpg" alt="The Orangry"><em>The Orangry</em></span></a>
                  </div>
<div>
duckboy1981
 
Posts: 6
Joined: Fri Sep 19, 2008 1:36 pm

Postby flabbyrabbit on Fri Sep 19, 2008 4:55 pm

The way I would do is like this:
[php]
<?php
$name = "The Orangry";
$location = "img/Marketing/Summer Drinks/SummerDrinks2008_01.jpg";
?>

<div class="gallery">
<div class="thumb">
<a href="javascript:DisplayImage('<?php echo $location; ?>','300','225','<?php echo $name; ?>')">
<img src="" alt="<?php echo $name; ?>" width="149" height="112"
onmouseover="window.status='Summer Drinks 2008 - <?php echo $name; ?>';return true"
onmouseout="window.status='';return true">
<span><img src="<?php echo $location; ?>" alt="<?php echo $name; ?>"><em><?php echo $name; ?></em></span></a>
</div>
<div>[/php]
Where you can just change the variables at the top of the code.

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England

Postby nighthawk on Sun Sep 21, 2008 7:40 pm

Flabby Rabbit's code is good, but depending on server (php) configuration it may not run properly. If there are probles use <?php only on start, and then use just <? and ?>.
The Zeitgeist Movement
User avatar
nighthawk
250+ Club
 
Posts: 420
Joined: Sun Jun 11, 2006 1:53 pm
Location: SFRJ

Postby duckboy1981 on Mon Sep 22, 2008 11:05 am

Guys, many thanks for your replies, but unfortunatly I cannot get it to work :(

I copied and pasted first and then tried Nighthawks suggestion, but no joy.

It's displaying the telltale red cross suggesting the file cannot be found and displaying the name as the php code rather that the cantents of the variable, which suggests to me it may be to do with my settings, but I have no idea where to look. Any suggestions?

Thanks,
David
duckboy1981
 
Posts: 6
Joined: Fri Sep 19, 2008 1:36 pm

Postby nighthawk on Mon Sep 22, 2008 11:20 am

Try this one:

[php]
<?php
$name = "The Orangry";
$location = "img/Marketing/Summer Drinks/SummerDrinks2008_01.jpg";
?>

<div class="gallery">
<div class="thumb">
<a href="javascript:DisplayImage('<?php echo $location; ?>','300','225','<?php echo $name; ?>')">
<img src="<? echo $location; ?>" alt="<?php echo $name; ?>" width="149" height="112"
onmouseover="window.status='Summer Drinks 2008 - <?php echo $name; ?>';return true"
onmouseout="window.status='';return true">
<span><img src="<?php echo $location; ?>" alt="<?php echo $name; ?>"><em><?php echo $name; ?></em></span></a>
</div>
<div>
[/php]

src attribute was missing in one img tag.

You need to save the file with .php extension, and of course, you have to have php installed on the server.

Put this [php]<?php phpinfo(); ?>[/php]
in a file and save it as test.php. Then run (open in browser) it, and if you get bunch of stuff displayed on your screen then php is working, if you see just this code, then you don't have php installed on that server. If you do this with notepad make sure to save as type: All Files, otherwise it will save it as something.php.txt.
Last edited by nighthawk on Mon Sep 22, 2008 11:53 am, edited 2 times in total.
The Zeitgeist Movement
User avatar
nighthawk
250+ Club
 
Posts: 420
Joined: Sun Jun 11, 2006 1:53 pm
Location: SFRJ

Postby duckboy1981 on Mon Sep 22, 2008 11:49 am

I saw that and tried first of all but to no avail. Im gonna send you an e-mail with a screen shot so you can see what it is telling me.

Thanks,
David
duckboy1981
 
Posts: 6
Joined: Fri Sep 19, 2008 1:36 pm


Who is online

Users browsing this forum: No registered users and 0 guests