School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store | FORUMS
Class / Forums / php101 ![]() |
Week #4 Basic To-Do Assignment, post here |
(#6 2003-08-07 16:03:54) Post Reply |
|
TDavid
|
Week #4 Basic TO-DO ASSIGNMENT: Write a script to rotate banners kept inside an array stored using a separate file and using require() to bring into the main script which does the rotation.
Post this assignment here so that we can offer comment/critique for you, but also post a URL to the working copy of the script and post here the complete source code of the script in you post. scriptname.php <-- script name Good luck to you!
|
(#53 2003-08-17 14:15:37) Post Reply |
|
cplayers
|
Hi,
This is my two scripts and working URL - comments URL: http://www.online-players.com/...asic_rotate.php Banner Script: <HTML> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Script School - PHP Course Lesson 4 (basic File 1 of 2)</title> </head> <BODY> <? /* Array of Banners */ $banners = array("http://www.online-players.com/Graphics/468x60_june02.gif", "http://www.online-players.com/Graphics/468X60FREEBOX_GOLDBAR_25_50_75.gif", "http://www.online-players.com/Graphics/gcc_468x060_115.gif", "http://www.online-players.com/Graphics/op_gambling_portal_468x60_u12.gif"); ?> </HTML> </BODY> Main Script: <HTML> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Script School - PHP Course Lesson 4 (basic File 2 of 2)</title> </head> <BODY> <? require("/home/online-p/public_html/phplessons/lesson4_basic_array.php"); ?> <? mt_srand(time()); $random_index = (mt_rand(1, (count($banners))) - 1); print("<img border="0" src=" . $banners[$random_index] . ">"); ?> </HTML> </BODY> |
(#59 2003-08-17 19:20:00) Post Reply |
|
Sk8rRIMuk
|
Heres my banner rotation script:
Inside 'Week #4 Basic To-Do Assignment.php' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Week #4 Basic To-Do Assignment</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> </head> <body> <center> Here is our random banner:<br /> <?php require("random_baner.php"); ?> </center> </body> </html> Inside 'random_baner.php':
In the directory I have all the required pictures. I am still stuck on Week #3 Advanced. I will have ago at Week #4 Advanced some time this week. |
(#62 2003-08-19 07:15:15) Post Reply |
|
Sk8rRIMuk
|
My script is at:
http://www.katikai.com/ee/assi...0Assignment.php Sorry for the big link I just uploaded my scripting folder there. All my previous to-do assignments are at: http://www.katikai.com/ee/assi...Do%20Assignment |
(#89 2003-08-25 12:34:36) Post Reply |
|
Donnie
|
I have a script called bannerarray.php. It contains the following code:
if I execute the .php file, it works perfectly. If I open the html file, nothing is displayed. Just a blank page. Can anyone help me? Thanks. |
(#121 2003-08-29 15:35:20) Post Reply |
|
Donnie
|
I have two files:
First a php script called bannerarray.php:
If I just execute the php filefrom the browser, everything works great. If I open the html file, it doesn't work. Any suggestions? |
(#132 2003-08-29 21:40:00) Post Reply |
|
TDavid
|
Hi Donnie,
quote: Make sure the (html) page calling the script is set to parse for PHP. You might need to give it a php, phtml, php3 extension or have your host parse the html page for php. |
(#133 2003-08-29 21:41:35) Post Reply |
|
TDavid
|
cplayer - please make sure to use the [ code ] and [ /code ] tags around your php code so that the forum colorizes it.
Banner Script:
Like that, thanks ;) |
(#150 2003-09-02 10:47:18) Post Reply |
|
Donnie
|
OK, I have finished the basic assignment 4. I have two files; The first one assigns image files to to an array then randomly selects one. The second calls the first script then displays the randomly selected image.
First File
BTW - Thanks for fixing the backslash issue!!!! |
(#158 2003-09-03 19:34:39) Post Reply |
|
galacey
|
Working file:
http://www.helping-you-make-mo...ndom_banner.php
banners.php - external file that contains the array of banners |
(#171 2003-09-09 10:43:54) Post Reply |
|
Quicksaver
|
this was easy :)
banners.php:
working url |
(#172 2003-09-09 10:45:20) Post Reply |
|
Quicksaver
|
sorry, the second bit of code belongs to the file that the link goes to, not the banners.php (im pretty sure i wrote its name before the code but whatever) |
(#198 2003-09-13 16:46:12) Post Reply |
|
operations
|
http://members.lycos.co.uk/operations/
week4_basic_netsurprise.php : |
(#208 2003-09-15 09:58:49) Post Reply |
|
Shrek
|
Here is my assignment
Class04_banner.php
|
(#219 2003-09-16 19:51:59) Post Reply |
|
Nazz
|
<? /*This file "4th_assigmrnt_html.php" contains banner array to seed, calculate, and print banner*/ /*create banner array*/ $banner = array("9227.gif", "9246.gif", "9239.gif", "9251.gif"); /*seed random generator*/ mt_srand(time()); /*calculate random number*/ $random_banner = (mt_rand(1, (count($banner))) - 1); /*print to browser*/ print("<img src=\"$banner[$random_banner]\">"); ?> <? /* this file "4th_assignment_2_html.php" uses the require function*/ require("4th_assignmrnt_html.php"); ?> |
(#220 2003-09-16 19:57:59) Post Reply |
|
Nazz
|
sorry to post again but I forgot the closing code tag the first time.
|
(#258 2003-09-20 10:24:08) Post Reply |
|
merlin69
|
Here is my banner.php
the script works just fine however I am having a heck of a time getting the images to show. |
(#279 2003-09-26 09:08:36) Post Reply |
|
MarcusD79
|
This works quite well. Here is the link to the referrenced file:
http://www.fagfrat.com/phpclas...week4banner.php
and here is the file that displays: http://www.fagfrat.com/phpclass/week4.php Here is the reference file code, followed by the display file code: |
(#281 2003-09-26 15:55:14) Post Reply |
|
maddy
|
The fine containing the banners array (called banners.php), contains this code:
A working copy (I think) of the script can be found <a href="http://sassy.togetherhost.com/scripts/week4.php">here</a>. |
(#282 2003-09-26 15:59:48) Post Reply |
|
maddy
|
Well, obviously the second set of code is what contains the randomising code, and prints out the random image. I did put that in my first post, between the two sets of code, but I guess it got eaten. And now that I know that the forum doesn't have html enabled, here is the link for my script: http://sassy.togetherhost.com/...ripts/week4.php :) |
(#317 2003-10-13 14:11:30) Post Reply |
|
zxrod
|
Ok, for some reason its been taking me a little bit of time to get this whole "<img src=\"lala.jpg\">" but oh well. This seems to work.
Banners.php3 <html> <body> <title>Week 4 Basic Assignment</title>
</body> </html> |
(#333 2003-10-25 00:27:27) Post Reply |
|
willie565
|
Here's assignment 4 I've done 4 in one night so I think I'll take a break now.
http://www.megatech.com/~will/banner.php
banner.php: |
(#393 2003-11-19 17:21:18) Post Reply |
|
coinweb
|
Here it is, took some working.
This first script is the page that stores the array of banners. ++++++++++++++++++++++++++++++++++++++++++++++ <html> <head> <title>Homework for Week #4</title> </head> <body> <? /* TO-DO ASSIGNMENT: Write a script to rotate banners kept inside an array stored using a separate file and using require to bring into the main script which does the rotation. */ //This page is where the banners are stored //Array of banners to be displayed $banners = array("americanbanner.gif", "banner1.jpg", "oscommerce.gif", "rent_banner.gif"); ?> </body></html> +++++++++++++++++++++++++++++++++++++++++++++ This second script is the page that displays the banners. <html> <head> <title>Homework for Week #4</title> </head> <body bgcolor="blue"> <center><table width="75%" border="1" bgcolor="white"> <tr> <td> <?php /* TO-DO ASSIGNMENT: Write a script to rotate banners kept inside an array stored using a separate file and using require to bring into the main script which does the rotation. */ //This is the page that will actually display the banners. require("weekfour.php"); mt_srand(time()); $random_index = (mt_rand(1, (count($banners))) - 1); print("<center><img src=" . $banners[$random_index] . "></center>"); ?> </body> </HTML> |
(#416 2003-12-11 08:15:36) Post Reply |
|
fudded
|
I have 2 files in the same directory
1st the banners |
(#434 2003-12-28 00:04:28) Post Reply |
|
n2o2k
|
2 Files: main file and rotate file
here is the main file: |
(#440 2003-12-29 19:44:59) Post Reply |
|
PureGrain
|
File name:lesson4basic_final.php
<a href="http://12.202.159.36/scriptschool/lesson4basic_final.php">Working link</a> File 1: File containing the array.
|
(#477 2004-01-17 11:00:06) Post Reply |
|
Ash2k4
|
week4basic.php
|
(#478 2004-01-17 11:04:07) Post Reply |
|
Ash2k4
|
(sorry for reposting... I posted incorrectly above) |
(#480 2004-01-19 15:21:37) Post Reply |
|
vladdrac
|
here is the working url http://vladdracworld.hostrocke...ests/pathto.php
here is the working code
|
(#493 2004-02-05 06:21:35) Post Reply |
|
ScriptME
|
I got my Script to work but, I know its not perfect. Is there a way to do a count on a multi-dimensional array? How would I use a count in the following code to count the number of elements in the Banner Array?
Thanks in advance, ScriptME |
View Previous Thread Print This Page |
School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store
Advertising
| Link To Us | Privacy
Copyright 2000-2002 Script School Productions / KMR
Enterprises
No part of this website may be reproduced, copied and/or distributed
in any medium
without express written permission