photodow Posted March 11, 2007 Share Posted March 11, 2007 I am trying to write a php script, but I am having trouble with my links. I'm not sure what I'm doing wrong, so any help would be appreciated. Here is the basic part of my script that I'm wanting it to do. The actual script is a tad more complicated, but not much. Just thought I would shorten it. <?php $week = date("W"); If ($week<"14") { [<a href="#" onclick="window.open('year3/1_10.php', 'mywindow', 'width=500,height=350,resizable=no');"><font color=#808000>First Quarter</font></a>] } else { <a href="#" onclick="window.open('year3/1_10.php', 'mywindow', 'width=500,height=350,resizable=no');"><font color=#808000>First Quarter</font></a> } ?> Again, thanks for any help you can provide! Link to comment https://forums.phpfreaks.com/topic/42190-solved-linking-problem/ Share on other sites More sharing options...
tauchai83 Posted March 11, 2007 Share Posted March 11, 2007 at least tell us what the error you get. error message. Link to comment https://forums.phpfreaks.com/topic/42190-solved-linking-problem/#findComment-204641 Share on other sites More sharing options...
photodow Posted March 11, 2007 Author Share Posted March 11, 2007 Oh, I'm sry. Error: Parse error: syntax error, unexpected '[' in /home/photodow/public_html/testarea.php on line 119 Link to comment https://forums.phpfreaks.com/topic/42190-solved-linking-problem/#findComment-204642 Share on other sites More sharing options...
photodow Posted March 11, 2007 Author Share Posted March 11, 2007 Alright looking back at my code I realized I didn't have the "echo". So I changed that, and got this. <?php $week = date("W"); If ($week<"14") { echo "[<a href="#" onclick="window.open('year3/1_10.php', 'mywindow', 'width=500,height=350,resizable=no');"><font color=#808000>First Quarter</font></a>]"; } else { echo "<a href="#" onclick="window.open('year3/1_10.php', 'mywindow', 'width=500,height=350,resizable=no');"><font color=#808000>First Quarter</font></a>"; } ?> But now there is another error saying: Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/photodow/public_html/testarea.php on line 120 Link to comment https://forums.phpfreaks.com/topic/42190-solved-linking-problem/#findComment-204644 Share on other sites More sharing options...
jeremywesselman Posted March 11, 2007 Share Posted March 11, 2007 <?php $week = date("W"); if ($week<"14") { echo '[<a href="#" onclick="window.open(\'year3/1_10.php\', \'mywindow\', \'width=500,height=350,resizable=no\');"><font color=#808000>First Quarter</font></a>]'; } else { echo '<a href="#" onclick="window.open(\'year3/1_10.php\', \'mywindow\', \'width=500,height=350,resizable=no\');"><font color=#808000>First Quarter</font></a>' ; } ?> That is one way you can do it. Another: <?php $week = date("W"); if ($week<"14"): ?> [<a href="#" onclick="window.open('year3/1_10.php', 'mywindow', 'width=500,height=350,resizable=no');"><font color=#808000>First Quarter</font></a>] <?php else: ?> <a href="#" onclick="window.open('year3/1_10.php', 'mywindow', 'width=500,height=350,resizable=no');"><font color=#808000>First Quarter</font></a> <?php endif; ?> Link to comment https://forums.phpfreaks.com/topic/42190-solved-linking-problem/#findComment-204646 Share on other sites More sharing options...
photodow Posted March 11, 2007 Author Share Posted March 11, 2007 Hmm... I've always learned to do it the other way, but this way seems to work. Thanks alot! Link to comment https://forums.phpfreaks.com/topic/42190-solved-linking-problem/#findComment-204808 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.