|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
I am very new to PHP and have very limited knowledge but am learning. I have found a really great php script for image rotating links but am stuck as to how to make the links execute to a new window if needed to. The script has come from http://www.jab.poundingbeats.com/index.php?id=2 and yes I have mailed the man responsible for it with my question but without reply. The part I am coming unstuck with is adding a $sites[0] = array(http://www.site1.com target="_blank", "Text1", 5, "images/mybannerimage1.jpg"); $sites[1] = array("http://www.site2.com onclick="target='newwindow'"", "Text2", 1, "images/mybannerimage2.jpg"); $sites[2] = array("http://www.site3.com", "Text3", 5, "images/mybannerimage3.jpg"); $sites[3] = array("http://www.site1.com", "Text1", 1, "images/mybannerimage4.jpg"); Now I know that neither the target_blank or the onclick work because they won't parse, is there another way or am I missing something. If this is a ridiculous question then sorry but any would be greatly appreciated. Andrew |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
@Homeonthecouch wrote:
> Hello, > > I am very new to PHP and have very limited knowledge but am learning. > > I have found a really great php script for image rotating links but am stuck > as to how to make the links execute to a new window if needed to. > > > > The script has come from http://www.jab.poundingbeats.com/index.php?id=2 and > yes I have mailed the man responsible for it with my question but without > reply. > > > > The part I am coming unstuck with is adding a > > $sites[0] = array(http://www.site1.com target="_blank", "Text1", 5, > "images/mybannerimage1.jpg"); > $sites[1] = array("http://www.site2.com onclick="target='newwindow'"", > "Text2", 1, "images/mybannerimage2.jpg"); > $sites[2] = array("http://www.site3.com", "Text3", 5, > "images/mybannerimage3.jpg"); > $sites[3] = array("http://www.site1.com", "Text1", 1, > "images/mybannerimage4.jpg"); > > > > Now I know that neither the target_blank or the onclick work because they > won't parse, is there another way or am I missing something. Without looking at the source, I think the url part in the array will be inserted into the href value in the anchor tag. Whet you need to do is to find which part of the code that types out the anchor tag and there add the target=_new option. With other words you are in the wrong place in the code and make changes, the place you are playing with just causes the HTML to be wrong. -- //Aho |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
I don't think I explained this very well.
I know the onclick and the target wont parse. I also know that when the relative data is pulled from the php into the HTML it wont validate because Target is not valid in "strict dtd" What I wanted, was to find a way to make some of the links load into the current browser window and some to load to a new browser window. The links I am using aren't relevant but they all load to the current browser webpage. $sites[0] = array("http://www.site4.com", "Text5", 2, "images/mybannerimage3.jpg"); $sites[1] = array("http://www.site2.com", "Text3", 5, "images/mybannerimage3.jpg"); $sites[2] = array("http://www.site3.com", "Text3", 5, "images/mybannerimage3.jpg"); $sites[3] = array("http://www.site1.com", "Text1", 1, "images/mybannerimage4.jpg"); Hope this explains it a little clearer? Andrew "J.O. Aho" <user@example.net> wrote in message news:5rvtoaF1701g6U1@mid.individual.net... > @Homeonthecouch wrote: >> Hello, >> >> I am very new to PHP and have very limited knowledge but am learning. >> >> I have found a really great php script for image rotating links but am >> stuck >> as to how to make the links execute to a new window if needed to. >> >> >> >> The script has come from http://www.jab.poundingbeats.com/index.php?id=2 >> and >> yes I have mailed the man responsible for it with my question but without >> reply. >> >> >> >> The part I am coming unstuck with is adding a >> >> $sites[0] = array(http://www.site1.com target="_blank", "Text1", 5, >> "images/mybannerimage1.jpg"); >> $sites[1] = array("http://www.site2.com onclick="target='newwindow'"", >> "Text2", 1, "images/mybannerimage2.jpg"); >> $sites[2] = array("http://www.site3.com", "Text3", 5, >> "images/mybannerimage3.jpg"); >> $sites[3] = array("http://www.site1.com", "Text1", 1, >> "images/mybannerimage4.jpg"); >> >> >> >> Now I know that neither the target_blank or the onclick work because they >> won't parse, is there another way or am I missing something. > > Without looking at the source, I think the url part in the array will be > inserted into the href value in the anchor tag. Whet you need to do is to > find > which part of the code that types out the anchor tag and there add the > target=_new option. > > With other words you are in the wrong place in the code and make changes, > the > place you are playing with just causes the HTML to be wrong. > > > -- > > //Aho |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
@Homeonthecouch wrote:
> I don't think I explained this very well. > > I know the onclick and the target wont parse. > > I also know that when the relative data is pulled from the php into the HTML > it wont validate because Target is not valid in "strict dtd" > > What I wanted, was to find a way to make some of the links load into the > current browser window and some to load to a new browser window. > > The links I am using aren't relevant but they all load to the current > browser webpage. 1. You need to modify the array that you create 2. You need to locate where the array is "echoed" out and modify the code there to handle the new cell in the array > $sites[0] = array("http://www.site4.com", "Text5", 2, > "images/mybannerimage3.jpg"); Change to: $sites[] = array("http://www.site4.com","Text5", 2,"images/mybannerimage3.jpg", true); $sites[] = array("http://www.site2.com", "Text3", 5, "images/mybannerimage3.jpg",false); Where false could be the same as open in current page and true to open i n a new. Look for a code that could look something like $site=$sites[rand(0,count($sites))]; echo "<a href=\"{$site[0]}\"><img src=\"{$site[3]}\" alt=\"{$site[1]}\"></a>"; and change it to something like $site=$sites[rand(0,count($sites))]; echo "<a href=\"{$site[0]}\""; if($site[4]) echo " target=_new"; echo "><img src=\"{$site[3]}\" alt=\"{$site[1]}\"></a>"; Keep in mind that the code may look completely different from what I wrote here, but should give you some kind of guideline what to look and how to add the change you want. -- //Aho |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Got to be easier if I just post the whole lot so your not guessing,
Someone else has asked this question on the owners website but he says he will be busy with studies until November so I guess it over ran whatever it was he was studying. Here's the whole lot then. I really appreciate your and patience with this. If there is a 'target' value added in, will it still validate in strict dtd mode? <?php $option = "banner"; $sites[0] = array("http://www.site1.com", "Text1", 5, "images/mybannerimage1.jpg"); $sites[1] = array("http://www.site2.com", "Text2", 1, "images/mybannerimage2.jpg"); $sites[2] = array("http://www.site3.com", "Text3", 5, "images/mybannerimage3.jpg"); $sites[3] = array("http://www.site1.com", "Text1", 1, "images/mybannerimage4.jpg"); $countsites = count($sites); for($i=0; $i<$countsites; $i++) { for($x=0; $x<$sites[$i][2]; $x++) { if($option != null) { $mylist[] = array($sites[$i][0],$sites[$i][1],$sites[$i][3]); } else { echo("Error deciding option."); exit(); } } } $countlist = count($mylist); $countlist = $countlist - 1; $picker = rand(0, $countlist); if($option == "link") { echo("<a href='" . $mylist[$picker][0] . "'>" . $mylist[$picker][1] . "</a>"); } else if($option == "banner") { echo("<a href='" . $mylist[$picker][0] . "'><img alt='" . $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"); } else { echo("Error deciding option."); exit(); } //Created by James Barnsley. All rights reserved. ?> |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
@Homeonthecouch wrote:
> Got to be easier if I just post the whole lot so your not guessing, > Someone else has asked this question on the owners website but he says > he will be busy with studies until November so I guess it over ran > whatever it was he was studying. > > > Here's the whole lot then. > > I really appreciate your and patience with this. > If there is a 'target' value added in, will it still validate in strict > dtd mode? > > > > <?php > > $option = "banner"; > > $sites[0] = array("http://www.site1.com", "Text1", 5, > "images/mybannerimage1.jpg"); > $sites[1] = array("http://www.site2.com", "Text2", 1, > "images/mybannerimage2.jpg"); > $sites[2] = array("http://www.site3.com", "Text3", 5, > "images/mybannerimage3.jpg"); > $sites[3] = array("http://www.site1.com", "Text1", 1, > "images/mybannerimage4.jpg"); > > > $countsites = count($sites); > > for($i=0; $i<$countsites; $i++) > { > for($x=0; $x<$sites[$i][2]; $x++) > { > if($option != null) > { > $mylist[] = array($sites[$i][0],$sites[$i][1],$sites[$i][3]); > } > else > { > echo("Error deciding option."); > exit(); > } > } > } > > $countlist = count($mylist); > > $countlist = $countlist - 1; > > $picker = rand(0, $countlist); > > if($option == "link") > { > echo("<a href='" . $mylist[$picker][0] . "'>" . $mylist[$picker][1] . > "</a>"); > } > > else if($option == "banner") > { > echo("<a href='" . $mylist[$picker][0] . "'><img alt='" . > $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"); > } > > else > { > echo("Error deciding option."); > exit(); > } > > //Created by James Barnsley. All rights reserved. > > ?> > Your biggest problem is that PHP cannot control whether something is opened in a new window or not. That's strictly client-side - html and/or javascript. What you need to do is first of all determine the html code you want to generate. alt.html will you here. Once you have that, the php code should be easy. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Sat, 08 Dec 2007 18:52:47 GMT, in alt.php "@Homeonthecouch"
<me@home.com> <3KB6j.71057$EU1.17768@fe1.news.blueyonder.co.uk > wrote: >| Got to be easier if I just post the whole lot so your not guessing, >| Someone else has asked this question on the owners website but he says he will be busy with studies until November so I guess it over ran whatever it was he was studying. >| >| >| Here's the whole lot then. >| >| I really appreciate your and patience with this. >| If there is a 'target' value added in, will it still validate in strict dtd mode? >| >| >| <?php >| >| $option = "banner"; >| >| $sites[0] = array("http://www.site1.com", "Text1", 5, "images/mybannerimage1.jpg"); >| $sites[1] = array("http://www.site2.com", "Text2", 1, "images/mybannerimage2.jpg"); >| $sites[2] = array("http://www.site3.com", "Text3", 5, "images/mybannerimage3.jpg"); >| $sites[3] = array("http://www.site1.com", "Text1", 1, "images/mybannerimage4.jpg"); Step 1. Add a flag to each item to tell the HTML section what to do. So your $site array will look like (reduced info for line wrap): $sites[0]=array("http://www.s1.com","Text1",5,"myb1.jpg",true); $sites[1]=array("http://www.s2.com","Text2",1,"myb2.jpg",false); $sites[2]=array("http://www.s3.com","Text3",5,"myb3.jpg",false); $sites[3]=array("http://www.s1.com","Text1",1,"myb4.jpg",true); >| $countsites = count($sites); >| >| for($i=0; $i<$countsites; $i++) >| { >| for($x=0; $x<$sites[$i][2]; $x++) >| { >| if($option != null) >| { >| $mylist[] = array($sites[$i][0],$sites[$i][1],$sites[$i][3]); Step 2. Include the flag within the list $mylist[]=array($sites[$i][0],$sites[$i][1],$sites[$i][3],$sites[$i][4]); >| } >| else >| { >| echo("Error deciding option."); >| exit(); >| } >| } >| } >| >| $countlist = count($mylist); >| >| $countlist = $countlist - 1; >| >| $picker = rand(0, $countlist); >| >| if($option == "link") >| { >| echo("<a href='" . $mylist[$picker][0] . "'>" . $mylist[$picker][1] . "</a>"); >| } >| >| else if($option == "banner") >| { >| echo("<a href='" . $mylist[$picker][0] . "'><img alt='" . $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"); Step 3. Insert appropriate code depending upon the flag echo "<a href='" . $mylist[$picker][0] . "'"; if( $mylist[$picker][0] == true ) { echo " target='_blank'"; } //--- finish of the rest of the HTML echo "><img alt='" . $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"; >| } >| >| else >| { >| echo("Error deciding option."); >| exit(); >| } >| >| //Created by James Barnsley. All rights reserved. >| >| ?> -- ------------------------------------------------------------- jnorthau@yourpantsyahoo.com.au : Remove your pants to reply -- ------------------------------------------------------------- |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Thanks for that Jeff
I have done the steps and have now got an error that reads Parse error: parse error, unexpected ';' on line 41 Below is line 41 echo("<a href='" . $mylist[$picker][0] . " '"; if( $mylist[$picker][0] == true ) {echo " target='_blank'";}echo "><img alt='" . $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"); I have removed the ; in all the places but no change. Any ideas? Andrew "Jeff North" <jnorthau@yahoo.com.au> wrote in message news:b4fml39tg7co8ls33m15th1v4s1g6me3g6@4ax.com... > On Sat, 08 Dec 2007 18:52:47 GMT, in alt.php "@Homeonthecouch" > <me@home.com> > <3KB6j.71057$EU1.17768@fe1.news.blueyonder.co.uk > wrote: > >>| Got to be easier if I just post the whole lot so your not guessing, >>| Someone else has asked this question on the owners website but he says he will be busy with studies until November so I guess it over ran whatever it was he was studying. >>| >>| >>| Here's the whole lot then. >>| >>| I really appreciate your and patience with this. >>| If there is a 'target' value added in, will it still validate in strict dtd mode? >>| >>| >>| <?php >>| >>| $option = "banner"; >>| >>| $sites[0] = array("http://www.site1.com", "Text1", 5, "images/mybannerimage1.jpg"); >>| $sites[1] = array("http://www.site2.com", "Text2", 1, "images/mybannerimage2.jpg"); >>| $sites[2] = array("http://www.site3.com", "Text3", 5, "images/mybannerimage3.jpg"); >>| $sites[3] = array("http://www.site1.com", "Text1", 1, "images/mybannerimage4.jpg"); > > Step 1. Add a flag to each item to tell the HTML section what to do. > So your $site array will look like (reduced info for line wrap): > $sites[0]=array("http://www.s1.com","Text1",5,"myb1.jpg",true); > $sites[1]=array("http://www.s2.com","Text2",1,"myb2.jpg",false); > $sites[2]=array("http://www.s3.com","Text3",5,"myb3.jpg",false); > $sites[3]=array("http://www.s1.com","Text1",1,"myb4.jpg",true); > > >>| $countsites = count($sites); >>| >>| for($i=0; $i<$countsites; $i++) >>| { >>| for($x=0; $x<$sites[$i][2]; $x++) >>| { >>| if($option != null) >>| { >>| $mylist[] = array($sites[$i][0],$sites[$i][1],$sites[$i][3]); > > Step 2. Include the flag within the list > $mylist[]=array($sites[$i][0],$sites[$i][1],$sites[$i][3],$sites[$i][4]); > >>| } >>| else >>| { >>| echo("Error deciding option."); >>| exit(); >>| } >>| } >>| } >>| >>| $countlist = count($mylist); >>| >>| $countlist = $countlist - 1; >>| >>| $picker = rand(0, $countlist); >>| >>| if($option == "link") >>| { >>| echo("<a href='" . $mylist[$picker][0] . "'>" . $mylist[$picker][1] . "</a>"); >>| } >>| >>| else if($option == "banner") >>| { >>| echo("<a href='" . $mylist[$picker][0] . "'><img alt='" . $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"); > > Step 3. Insert appropriate code depending upon the flag > echo "<a href='" . $mylist[$picker][0] . "'"; > if( $mylist[$picker][0] == true ) { > echo " target='_blank'"; > } > //--- finish of the rest of the HTML > echo "><img alt='" . $mylist[$picker][1] . "' src='" . > $mylist[$picker][2] . "' /></a>"; > >>| } >>| >>| else >>| { >>| echo("Error deciding option."); >>| exit(); >>| } >>| >>| //Created by James Barnsley. All rights reserved. >>| >>| ?> > -- ------------------------------------------------------------- > jnorthau@yourpantsyahoo.com.au : Remove your pants to reply > -- ------------------------------------------------------------- |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
@Homeonthecouch wrote:
> Thanks for that Jeff > > I have done the steps and have now got an error that reads > > Parse error: parse error, unexpected ';' on line 41 > > Below is line 41 > > > echo("<a href='" . $mylist[$picker][0] . " '"; if( $mylist[$picker][0] > == true ) {echo " target='_blank'";}echo "><img alt='" . > $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"); > > > I have removed the ; in all the places but no change. > Any ideas? > > Andrew > Of course - your html is invalid. Let's reformat it so it makes some sense: echo("<a href='" . $mylist[$picker][0] . " '"; if( $mylist[$picker][0] == true ) { echo " target='_blank'"; } echo "><img alt='" . $mylist[$picker][1] . "' src='" . mylist[$picker][2] . "' /></a>"); Note the first line has unmatched parens, for instance. The first thing you need to do is format your PHP properly; a lot of times obvious errors show up immediately. Another thing which will is to get a syntax-highlighting editor. I use Crimson editor, which isn't necessarily the best for PHP, but works with several languages and does what I need. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
On Sun, 09 Dec 2007 23:14:54 GMT, in alt.php "@Homeonthecouch"
<me@home.com> <OF_6j.21681$kt3.4729@fe3.news.blueyonder.co.uk> wrote: >| Thanks for that Jeff >| >| I have done the steps and have now got an error that reads >| >| Parse error: parse error, unexpected ';' on line 41 >| >| Below is line 41 >| >| echo("<a href='" . $mylist[$picker][0] . " '"; if( $mylist[$picker][0] == true ) {echo " target='_blank'";}echo "><img alt='" . $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"); >| >| >| I have removed the ; in all the places but no change. >| Any ideas? >| >| Andrew I agree with Jerry. Properly formatted code makes the code, and any errors, easier to detect. Regarding text editors. There are numerous ones out there. I use either Textpad or Notepad++. Notepad++ has better syntax and bracket highlighting features. [snip] -- ------------------------------------------------------------- jnorthau@yourpantsyahoo.com.au : Remove your pants to reply -- ------------------------------------------------------------- |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
Jerry Stuckle wrote:
> @Homeonthecouch wrote: >> Thanks for that Jeff >> >> I have done the steps and have now got an error that reads >> >> Parse error: parse error, unexpected ';' on line 41 >> >> Below is line 41 >> >> >> echo("<a href='" . $mylist[$picker][0] . " '"; if( $mylist[$picker][0] >> == true ) {echo " target='_blank'";}echo "><img alt='" . >> $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"); >> >> >> I have removed the ; in all the places but no change. >> Any ideas? >> >> Andrew >> > > Of course - your html is invalid. Let's reformat it so it makes some > sense: > > echo("<a href='" . $mylist[$picker][0] . " '"; > if( $mylist[$picker][0] == true ) { > echo " target='_blank'"; > } > echo "><img alt='" . $mylist[$picker][1] . "' src='" . > mylist[$picker][2] . "' /></a>"); > > Note the first line has unmatched parens, for instance. > > The first thing you need to do is format your PHP properly; a lot of > times obvious errors show up immediately. > > Another thing which will is to get a syntax-highlighting editor. I > use Crimson editor, which isn't necessarily the best for PHP, but works > with several languages and does what I need. > > > I mean your PHP is invalid... -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
Jerry,
Thank you for the advice. I am a total novice and have obtained this script, without the added opening some pages in a new window, from the net. The came from Jeff. Jeff, The code you gave me was the code that wouldn't work? Any is always appreciated. Andrew. "Jeff North" <jnorthau@yahoo.com.au> wrote in message news:j53ql3hvc40brcug2hgv91dfcr8i9329bq@4ax.com... > On Sun, 09 Dec 2007 23:14:54 GMT, in alt.php "@Homeonthecouch" > <me@home.com> > <OF_6j.21681$kt3.4729@fe3.news.blueyonder.co.uk> wrote: > >>| Thanks for that Jeff >>| >>| I have done the steps and have now got an error that reads >>| >>| Parse error: parse error, unexpected ';' on line 41 >>| >>| Below is line 41 >>| >>| echo("<a href='" . $mylist[$picker][0] . " '"; if( $mylist[$picker][0] >>== true ) {echo " target='_blank'";}echo "><img alt='" . >>$mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>"); >>| >>| >>| I have removed the ; in all the places but no change. >>| Any ideas? >>| >>| Andrew > > I agree with Jerry. Properly formatted code makes the code, and any > errors, easier to detect. > > Regarding text editors. There are numerous ones out there. I use > either Textpad or Notepad++. Notepad++ has better syntax and bracket > highlighting features. > > [snip] > -- ------------------------------------------------------------- > jnorthau@yourpantsyahoo.com.au : Remove your pants to reply > -- ------------------------------------------------------------- |
|
|
|
#13 |
|
Messages: n/a
Hébergeur: |
On Mon, 10 Dec 2007 19:36:18 GMT, in alt.php "@Homeonthecouch"
<me@home.com> <Syg7j.84549$EU1.34563@fe1.news.blueyonder.co.uk > wrote: >| Jerry, >| Thank you for the advice. >| I am a total novice and have obtained this script, without the added opening >| some pages in a new window, from the net. >| The came from Jeff. >| >| Jeff, >| The code you gave me was the code that wouldn't work? >| >| Any is always appreciated. The code I gave you did work. You introduced the error by using echo ( Remove the ( and all will be well. [snip] -- ------------------------------------------------------------- jnorthau@yourpantsyahoo.com.au : Remove your pants to reply -- ------------------------------------------------------------- |
|
|
|
#14 |
|
Messages: n/a
Hébergeur: |
Many thanks to Jeff and Jerry.
You have been very ful. Andrew |
|
![]() |
| Outils de la discussion | |
|
|