Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

PHP Banner

Question posted by: infoseekar (Member) on May 7th, 2008 09:29 AM
Hi

I am trying to create a banner in PHP and I don't know where to start from. I have a picture to put as banner but I dont know how to write a php script/code for it. It would be great if someone can teach or put me in right direction.

Thanks
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
markusn00b's Avatar
markusn00b
Expert
1,812 Posts
May 7th, 2008
09:58 AM
#2

Re: PHP Banner
Quote:
Originally Posted by infoseekar
Hi

I am trying to create a banner in PHP and I don't know where to start from. I have a picture to put as banner but I dont know how to write a php script/code for it. It would be great if someone can teach or put me in right direction.

Thanks


Hm, what does the banner do? If it's a simple image then why not just display it using <img src="img_location.ext" /> ?

Maybe I'm missing the problem :P

Reply
infoseekar's Avatar
infoseekar
Member
32 Posts
May 7th, 2008
10:07 AM
#3

Re: PHP Banner
Quote:
Originally Posted by markusn00b
Hm, what does the banner do? If it's a simple image then why not just display it using <img src="img_location.ext" /> ?

Maybe I'm missing the problem :P


Thanks for replaying.. you are right it's a simple image. I want that picture on the top. and what about if that banner going to be animated. Will i be using same script or different.

thanks

Reply
markusn00b's Avatar
markusn00b
Expert
1,812 Posts
May 7th, 2008
10:27 AM
#4

Re: PHP Banner
Quote:
Originally Posted by infoseekar
Thanks for replaying.. you are right it's a simple image. I want that picture on the top. and what about if that banner going to be animated. Will i be using same script or different.

thanks


How will the banner be animated?

Reply
infoseekar's Avatar
infoseekar
Member
32 Posts
May 7th, 2008
10:35 AM
#5

Re: PHP Banner
Quote:
Originally Posted by markusn00b
How will the banner be animated?


The script you gave me is working but instead of a picture i only see a box.

Banner would be just flashing text or images..

thanks

Reply
infoseekar's Avatar
infoseekar
Member
32 Posts
May 7th, 2008
10:46 AM
#6

Re: PHP Banner
Quote:
Originally Posted by infoseekar
The script you gave me is working but instead of a picture i only see a box.

Banner would be just flashing text or images..

thanks



this script <img src="img_location.ext" /> is working when I replace it with <IMG SRC="img_location.ext" />..

Reply
markusn00b's Avatar
markusn00b
Expert
1,812 Posts
May 7th, 2008
10:53 AM
#7

Re: PHP Banner
I dont believe this is a php problem - more suited to HTML/CSS

Regards

Reply
harshmaul's Avatar
harshmaul
Expert
481 Posts
May 7th, 2008
10:55 AM
#8

Re: PHP Banner
Quote:
Originally Posted by infoseekar
this script <img src="img_location.ext" /> is working when I replace it with <IMG SRC="img_location.ext" />..


WOW.. have you got a proper doctype declaration in there? also out of curiosity what browser are you using. most browsers start crying if the element's attributes are in uppercase.

Reply
infoseekar's Avatar
infoseekar
Member
32 Posts
May 7th, 2008
10:58 AM
#9

Re: PHP Banner
Quote:
Originally Posted by harshmaul
WOW.. have you got a proper doctype declaration in there? also out of curiosity what browser are you using. most browsers start crying if the element's attributes are in uppercase.


i am using Internet Explorer.

Reply
harshmaul's Avatar
harshmaul
Expert
481 Posts
May 7th, 2008
11:01 AM
#10

Re: PHP Banner
post the generated markup... or a link in the html forums and i'll see what i can do to help.

Reply
TheServant's Avatar
TheServant
Needs Regular Fix
462 Posts
May 7th, 2008
10:18 PM
#11

Re: PHP Banner
Do you want to generate an image using php? I don't believe that you can do this animation you are trying to do with php. Once an image is generated and sent to the user from his page request, that script will not execute again until the page is refreshed. If that is what you want, that's fine, but if you want to be constantly generating new images, you will definately need either Javascript or AJAX.

If it is simply an image you have made in photoshop which is animated, then the code given above is all you need ( <img src=... alt="..." /> ). If that is not working, then it is your code that is buggy. Just confirm that you already have your animated image and you're not trying to generate one on the fly.

Reply
infoseekar's Avatar
infoseekar
Member
32 Posts
May 9th, 2008
07:56 AM
#12

Re: PHP Banner
Quote:
Originally Posted by TheServant
Do you want to generate an image using php? I don't believe that you can do this animation you are trying to do with php. Once an image is generated and sent to the user from his page request, that script will not execute again until the page is refreshed. If that is what you want, that's fine, but if you want to be constantly generating new images, you will definately need either Javascript or AJAX.

If it is simply an image you have made in photoshop which is animated, then the code given above is all you need ( <img src=... alt="..." /> ). If that is not working, then it is your code that is buggy. Just confirm that you already have your animated image and you're not trying to generate one on the fly.


Sorry Guys I didnt tell you that I am a beginner. I dont know anything about Java or AJAX. I am going to stick with ( <img src=... alt="..." /> ) for the time. Yes, I have a gif image. I am going try that.. Thansk for all your help.

Reply
coolsti's Avatar
coolsti
Familiar Sight
166 Posts
May 9th, 2008
10:25 PM
#13

Re: PHP Banner
Since you are rather new to all of this, something I would like to point out:

You do not need Ajax to make your page dynamically update an image. So you should not be concerned that you need to learn Ajax in order to do this. Ajax is just a way of doing something that was already available to you before Ajax was born. If you do indeed decide to have a page update its image dynamically, you just need some Javascript scripting to change the src attribute of your image tag.

That may make things seem less of a struggle to get started with something like this, in case you need it. And here we mean Javascript, not Java. Javascript is considerably easier to implement, it fits right in there with your HTML on your page, and is not all that difficult to get into.

Reply
dlite922's Avatar
dlite922
Needs Regular Fix
444 Posts
May 10th, 2008
07:46 AM
#14

Re: PHP Banner
Quote:
Originally Posted by coolsti
Since you are rather new to all of this, something I would like to point out:

You do not need Ajax to make your page dynamically update an image. So you should not be concerned that you need to learn Ajax in order to do this. Ajax is just a way of doing something that was already available to you before Ajax was born. If you do indeed decide to have a page update its image dynamically, you just need some Javascript scripting to change the src attribute of your image tag.

That may make things seem less of a struggle to get started with something like this, in case you need it. And here we mean Javascript, not Java. Javascript is considerably easier to implement, it fits right in there with your HTML on your page, and is not all that difficult to get into.


I think i know what your getting at. This is the simplest solution for him to implement:

Code: ( text )
  1. <html>
  2. <head>
  3. <!--
  4. This file retrieved from the JS-Examples archives
  5. 1000s of free ready to use scripts, tutorials, forums.
  6. Author: Doug Popeney - 0
  7. -->
  8.  
  9. </head>
  10. <body>
  11. <script language="JavaScript">
  12. <!-- Hide from old browsers
  13. var imagenumber = 5 ;
  14. var randomnumber = Math.random() ;
  15. var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
  16. images = new Array
  17. images[1] = "/js/pic1.gif"
  18. images[2] = "/js/pic2.gif"
  19. images[3] = "/js/pic3.gif"
  20. images[4] = "/js/pic4.gif"
  21. images[5] = "/js/pic1.gif"
  22. var image = images[rand1]
  23. links = new Array
  24. links[1] = "/"
  25. links[2] = "/"
  26. links[3] = "/"
  27. links[4] = "/"
  28. links[5] = "/"
  29. var link = links[rand1]
  30. // -- End Hiding Here -->
  31. </script>
  32.  
  33. <script language="JavaScript">
  34. <!-- Hide this script from old browsers -->
  35. document.write("<center><b>Reload this page</b></center><br><br>")
  36. document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" border="0"></a>')
  37. <!-- End Hiding Here -->
  38. </script>
  39. <BR><center><a href='http://www.js-examples.com'>JS-Examples.com</a></center>
  40. </body>
  41. </html>


Let me know if you have questions customizing the above.

First set number of images (its currently set to 5)

Then edit the lines that start with images[*number*]. If you have 4 images then you need to change these so its 1 through 4.

After the equal sign set where the image is located just like the <img src="image/path/here.jpg" />

Then the links is easy to do. Link[1] will be for images[1], linke[2] is for image [2].

If you don't want the image to link to anything set the link to "/" or "#".

Good luck,


-Dan

Source: http://www.js-x.com/page/javascript...e.html?view=666

Reply
Reply
Not the answer you were looking for? Post your question . . .
174,849 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top PHP Forum Contributors