Urbanturf Posted April 6, 2008 Share Posted April 6, 2008 Hey, sorry for being a total noobstick, but im just kinda learning php for my site... So heres the deal, im going to have a lot of pages, and i want to be able to show affiliates on that bottom bar, and every time i add or take off an affiliate i don't want to edit EVERY SINGLE PAGE... Heres the site: www.urbanturf.net/index so i figured i could make a file called "affiliates.php" and then on the index, or whatever page just put this code in <?PHP include("affiliates.php"); ?> and in affiliates.php i put this code in... <?php echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"700\"><tr><td align=\"center\" valign=\"top\"> <a href=\"http://www.munchymedia.com/\"><img src=\"affiliates/munchymedia.jpg\"></a> </td></tr></table>" }; ?> Can anyone help me? Sorry for being a total noob once again, and i would of looked for a tutorial, but i have no clue what they call this! if anyone can tell me what im doing wrong or help me find a tut id be very greatful and free Bj's.. THANKS Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/ Share on other sites More sharing options...
zfred09 Posted April 6, 2008 Share Posted April 6, 2008 Not sure if this is proper placement for this thread, anyways, you have the basic idea right with the include and external file, however you should create a function inside of the external file. Then on your pages you can call this function and it will display the info you want it to. in external file... function affiliates(){echo "I love all my affiliates.";} on each page include "file.php"; and when you call it... affiliates(); Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-510807 Share on other sites More sharing options...
Urbanturf Posted April 6, 2008 Author Share Posted April 6, 2008 Not sure if this is proper placement for this thread, anyways, you have the basic idea right with the include and external file, however you should create a function inside of the external file. Then on your pages you can call this function and it will display the info you want it to. in external file... function affiliates(){echo "I love all my affiliates.";} on each page include "file.php"; and when you call it... affiliates(); alright so in the affiliate.php (external) i put <?php function affiliates(){echo "I love all my affiliates.";} ?> and the index i put <?PHP include("affiliates.php"); ?> now it shows nothing >< Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-510818 Share on other sites More sharing options...
TheFilmGod Posted April 7, 2008 Share Posted April 7, 2008 now you got to call the function in the actual page... Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-510867 Share on other sites More sharing options...
ardyandkari Posted April 7, 2008 Share Posted April 7, 2008 ok. what i am gathering is this: you want to be able to advertise your affiliates at the bottom of the page. something like a "this site sponsored by" area. what you could do is have a random image script run. following is the random image script. dont remember where i got it, but oh well. <?php /* * Name your images 1.jpg, 2.jpg etc. * * Add this line to your page where you want the images to * appear: <?php include "randomimage.php"; ?> */ // Change this to the total number of images in the folder $total = "11"; // Change to the type of files to use eg. .jpg or .gif $file_type = ".jpg"; // Change to the location of the folder containing the images $image_folder = "images/random"; // You do not need to edit below this line $start = "1"; $random = mt_rand($start, $total); $image_name = $random . $file_type; echo "<img src=\"$image_folder/$image_name\" alt=\"$image_name\" />"; ?> copy and paste the code and save it as randomimage.php at the bottom of the page add a row and include the file. just make sure that the images are the right size. Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-510911 Share on other sites More sharing options...
zfred09 Posted April 7, 2008 Share Posted April 7, 2008 If you want the image script try that, otherwise all you need to do is call the function. So where you want "I love my affiliates to display" use this code. <?php affiliates();?> Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-511600 Share on other sites More sharing options...
Urbanturf Posted April 8, 2008 Author Share Posted April 8, 2008 im still not doing it right =( do i need to give my sql info or somin? anyone have aim or an instant messenger? this is what i got so far though... index.php .... <?php affiliates();?> affiliates.php <?php function affiliates(){echo "I love all my affiliates.";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-512517 Share on other sites More sharing options...
ardyandkari Posted April 9, 2008 Share Posted April 9, 2008 why in affiliates.php dont you just put the php code. dont make it a function. then you just include affiliates.php. what if you use single quotes in stead of double '/" ??? i dont know if that makes any difference or not, pretty new to php. Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-512580 Share on other sites More sharing options...
TheFilmGod Posted April 9, 2008 Share Posted April 9, 2008 now you called the function, but forgot to include() the file. - What is your experience with php? Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-512608 Share on other sites More sharing options...
unsider Posted April 9, 2008 Share Posted April 9, 2008 index.php <?php include("affiliates.php"); affiliates(); ?> affiliates.php <?php function affiliates() { echo "I love all my affiliates."; } ?> Clean up that code, and you forgot the include. Function is voided without. Curse you Film Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-512611 Share on other sites More sharing options...
Urbanturf Posted April 9, 2008 Author Share Posted April 9, 2008 GUYS IT WORKED!!!!!! THANKS SO MUCH!!!!!!1 you guys were so helpful, and no1 called me a dumb noob or anything lol appriciate it guys! Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-512645 Share on other sites More sharing options...
unsider Posted April 9, 2008 Share Posted April 9, 2008 GUYS IT WORKED!!!!!! THANKS SO MUCH!!!!!!1 you guys were so helpful, and no1 called me a dumb noob or anything lol appriciate it guys! That is one thing I respect about this community, I haven't seen any maligning, it's a learning enviroment sure, but even then you still expect some form of critisism, and that's pretty cool. Quote Link to comment https://forums.phpfreaks.com/topic/99883-website-affiliate-system/#findComment-512649 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.