el_bob Posted July 18, 2007 Share Posted July 18, 2007 hi - i've got a page someone else built with an include for another file. the include needed a random banner, both jpeg and swf. so i figured that one out - i've set up an include in that file which calls the proper code randomly from a text file, one line with the embed for the swf and one line with the image (both in their own link tag - a href...) so here's the issue - back on the top level, there's another banner which needs to be dependent on the include inside the include. they're in 2 completely different places, so tying them into the same file is not an option. i have ABSOLUTELY no idea where to even start on that one. anyone?? Quote Link to comment Share on other sites More sharing options...
lewis987 Posted July 18, 2007 Share Posted July 18, 2007 do you mean something like this? <?PHP //code before the head of the html ?> HTML HEAD STUFF <body> <?PHP //php code include 'xxx.xxx'; //more code include 'xxx.xxx'; //more code... ?> </body> END OF THE FILE if not then can you try and explain more clearly Quote Link to comment Share on other sites More sharing options...
el_bob Posted July 18, 2007 Author Share Posted July 18, 2007 sorry - i'll try to explain better here's the page hierarchy regular page header include.php banner randomizer include.php (getting html source code from text file) [*]more regular page stuff [*]other regular page banner which needs to be dependent on banner randomizer include.php result make more sense? Quote Link to comment Share on other sites More sharing options...
lewis987 Posted July 18, 2007 Share Posted July 18, 2007 not preticullary, im still stuck with what your saying, you mean a structure like this? index.php (for instance) |-include 'zzzz.php' ||-include 'yyyy.php' |-include 'xxxx.php' ||-include 'wwww.php' so you include 2 files, and both those files include more files? i really dont get what you mean, can you post the code? Quote Link to comment Share on other sites More sharing options...
el_bob Posted July 18, 2007 Author Share Posted July 18, 2007 sorry, i can't. but index.php |-include 'header.php' ||-include 'get_banner.php' |||random.txt (contains html to be placed into index.php, seperated by carriage returns) content skyscraper dependent on results of index/header/get_banner (THIS IS THE ONE I NEED) so i include one file, which includes another file, which feeds info into the index from yet another file. Quote Link to comment Share on other sites More sharing options...
lewis987 Posted July 18, 2007 Share Posted July 18, 2007 ok, all you need in the index.php file is: include 'xxxx.php' inside that you need: include 'xxxx.php' then add this inside that: include 'xxxx.txt' so then the index file will show the txt file along with the other files Index.php: include 'header.php'; header.php include 'get_banner.php'; get_banner.php include 'random.txt'; Quote Link to comment Share on other sites More sharing options...
el_bob Posted July 18, 2007 Author Share Posted July 18, 2007 right - i've already got that but let's say "random.txt" put the following line of code into index.php - <a href="http://www.joeschmoe.com" target"_blank"><img src="banners/joeschmoebanner.jpg" /></a> how do i then make sure that the next banner down gets the message that this is a joeschmoe page and not a fredschmed page, and loads a joeschmoe image accordingly? to cut off a few simple ideas already passed: can't have different pages - bookmark needs to always go back to index. can't setup a "joeschmoe" tag, cuz the doubly-nested "get_banner.php" won't get the message Quote Link to comment Share on other sites More sharing options...
el_bob Posted July 18, 2007 Author Share Posted July 18, 2007 ok, i think i fixeded it.... in the .txt file, i added an element id (same - banner) and a class (different - numbered 1-whatever for ease) in the index doc, i added a javascript to get the class of banner and write html code base on that NOW since my php is limited to looking at an existing script and twiddling with it once i see what links with what is there code to do this in php? here's the javascript <script language="JavaScript" type="text/javascript"> var el_banner = document.getElementById("banner"); if (el_banner.className=="1") { document.write ('<a href="http:\/\/www.joeschmoe.com" target="_blank"><img src="Banners\/joeschmoeTall.jpg" width="160" height="600"><\/a> '); } else { document.write ('<a href="http:\/\/www.fredschmed.com" target="_blank"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=7,0,19,0" width="160" height="600" title="fredschmed">') document.write ('<param name="movie" value="Banners\/fredschmedTall.swf">') document.write ('<param name="quality" value="high">') document.write ('<embed src="Banners\/fredschmedtall.swf" quality="high" pluginspage="http:\/\/www.macromedia.com\/go\/getflashplayer" type="application\/x-shockwave-flash" width="160" height="600"><\/embed>') document.write ('<\/object><\/a>'); } </script> Quote Link to comment Share on other sites More sharing options...
lewis987 Posted July 18, 2007 Share Posted July 18, 2007 try this: $chars = array('<a href="http://www.joeschmoe.com" target="_blank"><img src="Banners/joeschmoeTall.jpg" width="160" height="600"></a>', <a href="http:\/\/www.fredschmed.com" target="_blank"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=7,0,19,0" width="160" height="600" title="fredschmed">'); $length = 1; $textstr = ""; for ($i=0; $i<$length; $i++) { $textstr .= $chars[rand(0, count($chars)-1)]; } echo $textstr; Quote Link to comment Share on other sites More sharing options...
el_bob Posted July 18, 2007 Author Share Posted July 18, 2007 maybe i'm wrong, but you're giving me a script which puts in a random image, right? i've already decided up at the header what the random is, now i want to take that random decision and apply it to the side. Quote Link to comment Share on other sites More sharing options...
lewis987 Posted July 18, 2007 Share Posted July 18, 2007 ok, if you are using that code i just gave you, then just change it to: $chars = array('<a href="http://www.joeschmoe.com" target="_blank"><img src="Banners/joeschmoeTall.jpg" width="160" height="600"></a>', <a href="http:\/\/www.fredschmed.com" target="_blank"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=7,0,19,0" width="160" height="600" title="fredschmed">'); $length = 1; $textstr = ""; for ($i=0; $i<$length; $i++) { $textstr .= $chars[rand(0, count($chars)-1)]; } and then place this whereever you want it: echo $textstr; if its not that then just tell me Quote Link to comment Share on other sites More sharing options...
el_bob Posted July 19, 2007 Author Share Posted July 19, 2007 nope, fixed it so i just added the skyscraper code to the txt file using a --/-- delimiter, got the whole line using the carriage return delimiter, exploded the pieces using the --/-- and printed the pieces where i needed them. so the code is $filename = "random.txt"; $file = file($filename); srand((double)microtime()*1000000); while ($RandomRotator == "") { $RandomRotator = ereg_replace("\n","",$file[rand(0,count($file))]); } $pieces = explode("--/--", $RandomRotator); print $pieces[0]; and then later in the page print $pieces[1]; Quote Link to comment 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.