Calling images with PHP?

software development

#1

EDIT–never mind. I figured it out. But now I’m having trouble with pagination without database… ^^;; Any help?

I’m really confused…I can’t seem to find a function or anything that calls an already existing image with php. What I want to do is stick this in my if…else statement:

if ($stripid == 1)
{
echo (“This is strip 1”);
img src=“http://www.mad-as-sin.com/images/about.png
}

Someone told me that the HTML img src code works but apparently it doesn’t. Please help!


#2

you need to place it in your echo statement like this:
if ($stripid == 1)
{
echo "This is strip 1 <img src="http://www.mad-as-sin.com/images/about.png">";
}

don’t forget to add the \ before the double-quotes or it won’t render the code correctly.


#3

Well, it depends on how you’re organizing your data.

Firstly, you need to count the amount of files that you have. You can do that using this function:

function countfiles($path)
{
$i=0;
$dir = opendir($path);
while ($file = readdir($dir)){
{ $i ; }
}//end while
closedir($dir);
$i=$i-6;
return $i;
}

So let’s say you have 20 files, let’s echo that amount:

$numberOfFiles = countfiles("/path/to/your/files");
echo “$numberOfFiles”;

that will display the number 20.

Now to paginate.

let’s say we only want 5 results per page.

$numberOfPages = ($numberOfFiles / 5);
//divides the number of files by 5 in this example we get 4

$n = ceil($numberofpages);
//this forces the number to round up to the highest integer

for ($b=1; $b <= $n; $b )
{
$Res1=($b-1);
echo "$b ";
}
//this for loop will display page numbers

now the tricky part is getting the pages to display the correct information on each page. if you give me more info on how you store your data, i might be able to write up something, but otherwise i can’t give you an exact script. what i’ve written above should give you a decent starting point though. good luck :slight_smile: