Hi there,
I'm trying to create an image gallery, with (of course) for every
picture
the same javascript-pop-up. Because i use the same javascript, i only
want
to tell it the number of the image... Below is what i have, and it
works:
<?php $pic="01";list($width, $height, $type, $attr) =
getimagesize("./pix/$pic.jpg");
echo "<a href=\"javascript:MM_openBrWindow('foto.php?naam=$ pic&pic=./pix/$pic.jpg','dames3','width=$width,height=$height')\ "><img
src=\"./tmb/$pic.gif\" height=\"90\" width=\"90\" alt=\"$pic\"
/></a>";
?>
But when i copy it, and change $pic="01" to $pic="02", i get an error.
(Which
makes sense) But how can i tell the same script to take another
number..
The best would be something like <?php $pic="01"; print $script;
$pic="02"; print $script;
etc...
?>
$script would be everything of the earlier mentioned coding except for
'$pic = "..."' So you'd have to include it, but i can't even get that
to
work.. (I can't find a way to include php-script by calling it: echo
$script)
Hope you understand, thanks in advance..
Krunkelgarten 3 4309
"krunkelgarten" <kr***********@hotmail.com> wrote in message
news:87**************************@posting.google.c om... Hi there,
I'm trying to create an image gallery, with (of course) for every picture the same javascript-pop-up. Because i use the same javascript, i only want to tell it the number of the image... Below is what i have, and it works:
<?php $pic="01";list($width, $height, $type, $attr) = getimagesize("./pix/$pic.jpg"); echo "<a
href=\"javascript:MM_openBrWindow('foto.php?naam=$ pic&pic=./pix/$pic.jpg','d
ames3','width=$width,height=$height')\"><img src=\"./tmb/$pic.gif\" height=\"90\" width=\"90\" alt=\"$pic\" /></a>"; ?>
But when i copy it, and change $pic="01" to $pic="02", i get an error. (Which makes sense) But how can i tell the same script to take another number..
The best would be something like <?php $pic="01"; print $script; $pic="02"; print $script; etc... ?> $script would be everything of the earlier mentioned coding except for '$pic = "..."' So you'd have to include it, but i can't even get that to work.. (I can't find a way to include php-script by calling it: echo $script)
Hope you understand, thanks in advance..
Krunkelgarten
you can't put script in a variable (dont even mention my tools, thats
another story)
2 simple ways to do this:
1: wrap the script you mention info a function
<?php
bla...
bla...
bla...
showStuff("01");
showStuff("02");
showStuff("03");
function showStuff($pic)
{
(put all that code here)
}
?>
2: put it in an include file, and inlude it over and over
<?php
bla...
bla...
bla...
$pic = "01";
include("mystuff.php");
$pic = "02";
include("mystuff.php");
$pic = "03";
include("mystuff.php");
?>
--
Mike Bradley http://www.gzentools.com -- free online php tools
Hi there Count Scubula,
Is there any way i can contact you on this, and the image gallery?
Because it always takes so long to do it via Google.
I tried to mail you, but i get an error, could you please mail me
, you can se the right adress..
I'd greatly appreciate it..
Greetings Krunkelgarten
krunkelgarten wrote: Hi there,
I'm trying to create an image gallery, with (of course) for every picture the same javascript-pop-up. Because i use the same javascript, i only want to tell it the number of the image... Below is what i have, and it works:
<?php $pic="01";list($width, $height, $type, $attr) = getimagesize("./pix/$pic.jpg"); echo "<a href=\"javascript:MM_openBrWindow('foto.php?naam=$ pic&pic=./pix/$pic.jpg','dames3','width=$width,height=$height')\ "><img src=\"./tmb/$pic.gif\" height=\"90\" width=\"90\" alt=\"$pic\" /></a>"; ?>
But when i copy it, and change $pic="01" to $pic="02", i get an error. (Which makes sense) But how can i tell the same script to take another number..
The best would be something like <?php $pic="01"; print $script; $pic="02"; print $script; etc... ?> $script would be everything of the earlier mentioned coding except for '$pic = "..."' So you'd have to include it, but i can't even get that to work.. (I can't find a way to include php-script by calling it: echo $script)
Hope you understand, thanks in advance..
<?PHP
function print_link($pic) {
if (!file_exists("./pix/$pic.jpg") || !file_exists("./tmb/$pic.gif"))
return false;
list($width, $height, $type, $attr) = getimagesize("./pix/$pic.jpg");
echo "<a href = \"javascript :MM_openBrWindow(
'foto.php?naam=$pic&pic=./pix/$pic.jpg',
'dames3','width=$width,height=$height')\"><img
src=\"./tmb/$pic.gif\" height=\"90\" width=\"90\" alt=\"$pic\"/></a>";
return true;
}
?>
Then call whatever you want:
print_link("01");
print_link("02");
or read the directory:
if ($dir = opendir("./pix/")):
$files = array();
while ($file = readdir($dir)) {
if (preg_match("/.+\.jpg$/", $file))
array_push($files, preg_replace("/^(.+)\.jpg$/", "\\1", $file));
}
closedir($dir);
sort($files);
foreach($files as $pic) {
print_link($pic);
}
else:
echo "Directory does not exist.";
endif;
Regards,
Shawn
--
Shawn Wilson sh***@glassgiant.com http://www.glassgiant.com
I have a spam filter. Please include "PHP" in the
subject line to ensure I'll get your message. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Randell D. |
last post by:
Folks,
I've asked this before but never got any response but its important and I
thought I'd pitch it again (hopefully a bit clearer)...
One can pass data from one function to another either...
|
by: Seeker |
last post by:
Newbie question here...
I have a form with some radio buttons. To verify that at least one of the
buttons was chosen I use the following code ("f" is my form object) :
var btnChosen;
for...
|
by: wilson |
last post by:
Dear all,
In this time, I want to pass array to function.
What should I declare the parameter in the function?i
int array or int array? Which one is correct?
...
|
by: z_learning_tester |
last post by:
I'm reading the MS press C# book and there seems to be a contradiction.
Please tell me which one is correct, 1 or 2.
Thanks!
Jeff
1. First it gives the code below saying that it prints 0 then...
|
by: drec |
last post by:
I need to pass a variable from script1.php to script2.php. The problem
is that these scripts use frames and therefore I am able to pass the
variable through the URL. It also does not use forms to...
|
by: David++ |
last post by:
Hi folks,
I would be interested to hear peoples views on whether or not 'pass by
reference' is allowed when using a Web Service method.
The thing that troubles me about pass-by-reference into...
|
by: tshad |
last post by:
I want to access multiple arguments based on name passed.
For example I have the following asp:textboxes:
BillingAddress1
BillingAddress2
BillingCity
ShippingAddress1
ShippingAddress2...
|
by: Robert Dailey |
last post by:
Hi,
I noticed in Python all function parameters seem to be passed by
reference. This means that when I modify the value of a variable of a
function, the value of the variable externally from the...
|
by: Bryan Parkoff |
last post by:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope....
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms....
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |