Guest_imported
New member
- Jan 1, 1970
- 0
I don't know too much about PHP, but I CAN do a few things after staring at code for hours. I have a problem I don't even know if I can explain it right.
I think it has to do with passing variables. OKay here we go:
I have a main page and an 'Image Viewer' page. So when I want to link to a picture I simply wrtie this:
where on the image page I simply have:
It works just fine...
But NOW I want to have a little description of each image at the bottom of each picture with out writing something like this:
which I couldn;t get to work anyway when I tried it.
So Iput a little script at the top of the image/index.php page that looks like this:
the description.txt is just a simple flat textfile that reads
So it pulls the descritpion from the txt file.
OKay it works with
and
But it won't work with both like:
Did I explain it okay? Does anyone know what I should do? Feel free to email me if you want more info.
I think it has to do with passing variables. OKay here we go:
I have a main page and an 'Image Viewer' page. So when I want to link to a picture I simply wrtie this:
Code:
<a href="images/index.php?image=imagename.jpg">
Code:
<image src=<? print $image; ?> border=0>
It works just fine...
But NOW I want to have a little description of each image at the bottom of each picture with out writing something like this:
Code:
<a href=images/index.php?image=imagename.jpg?desc=A picture of my house>
which I couldn;t get to work anyway when I tried it.
So Iput a little script at the top of the image/index.php page that looks like this:
Code:
<?php
//--- default desc
$desc="No description available";
//--- read image data
$buffer=file("description.txt");
//--- convert to array
$data= array();
foreach ( $buffer as $line ){
$data[]=explode(";",$line);
}
$found=false;
$i=0;
while( $i<count($data) and !$found ){
if ( $id== $data[$i][0] ){
$desc=$data[$i][1];
$found=true;
}
$i++;
}
?>
the description.txt is just a simple flat textfile that reads
Code:
1;description of image goes here
So it pulls the descritpion from the txt file.
OKay it works with
Code:
<a href="images/index.php?image=imagename.jpg">
Code:
<a href="images/index.php?id=1">
But it won't work with both like:
Code:
<a href="images/index.php?image=imagename.jpg?id=1">
Did I explain it okay? Does anyone know what I should do? Feel free to email me if you want more info.