Results 1 to 8 of 8

Thread: Need help on one line please

  1. #1
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default Need help on one line please

    I am getting an error on this line and can't figure it out. Can someone please see what I am missing? Thanks.

    Code:
    echo "<td align=right><a href=\"/php/dayview.php?startdate=<?php echo $startdate['startdate'];?>\" . "\" class=\"dayofmonthyearview\">";
    Error Message:

    Code:
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home2/arakireg/public_html/_calmaui/php/yearview-new.php on line 115

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I don't know much about PHP, but I seriously doubt that you can open a <?php section within an echo statement (which itself should already be in a <?php section). If I get what you are after, this could work:

    PHP Code:
    echo "<td align=right><a href=\"/php/dayview.php?startdate=" $startdate['startdate'] . "\" class=\"dayofmonthyearview\">"
    or maybe even:

    PHP Code:
    echo '<td align="right"><a href="/php/dayview.php?startdate=' $startdate['startdate'] . '" class="dayofmonthyearview">'
    But either way:

    PHP Code:
    $startdate['startdate'
    will resolve as the page is served, not when the link is clicked. There is no PHP that will resolve when a link is clicked on a page. All PHP on a page is interpreted by the server just before serving the page.

    If you want dayview.php to have the most up to date value for:

    PHP Code:
    $startdate['startdate'
    get that value from the server on dayveiw.php, not from its URL.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    kuau (07-19-2008)

  4. #3
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Dear John: Thank you! That did get rid of the error. However, no matter what day you click on in the calendar, it just lists events for today's date. So I put this in dayview.php but it didn't help:

    Code:
    $today = date ('Y-m-d'); $daydate = date('l, F d, Y');
    			if(isset($_GET['startdate']) && is_numeric($_GET['startdate'])){
          $getdate = $_GET['startdate'];
    			} else {
    		  $getdate = $today;
        	}
          $query = " SELECT `event_id`,`event_title`, date_format(`startdate`, '%M %D, %Y') as startdate, time_format(`starttime`, '%h:%i %p') as starttime, time_format(`endtime`, '%h:%i %p') as endtime 
                     FROM `event`
                     WHERE `startdate` = '".$getdate."'                           
                     ORDER BY `starttime`, `event_title` ";    
          $result = @mysql_query($query,$connection) or die("Couldn't execute $query query."); ?>
          <div class="h1">EVENTS for <?php echo $daydate; ?></div>
          <p><? while($event = mysql_fetch_assoc($result)){ ?>
          <div class="day">
            <?php echo $event['starttime']; ?> - <?php echo $event['endtime']; ?>  &nbsp; <a href="/php/event-detail.php?event_id=<?php echo $event['event_id'];?>"> <?=$event['event_title'];?></a><br>
          </div>
          <? } ?></p>
    I tried to adapt Brady's code from last night for passing variables through the URL, but I'm not sure if it applies to date values (and I may have screwed it up). All I'm trying to do is link dayview.php to yearview.php based on what day you click on. Should be simple, but... Does your php extend that far? Thanks for your help.

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I haven't really followed all that code, yet. But it is becoming increasingly obvious to me that you probably want to produce something like:

    HTML Code:
    <a href="/php/dayview.php?startdate=somevalue">somevalue</a>
    in some sort of layout within a table. And I get the impression that you probably want that repeated for some kind of range of possible startdates.

    If these are stored in an array called $startdate, you should be able to iterate through that array with a PHP for each. That will write out the list of links.

    That's about the limit of my PHP knowledge though. Once you have that, if someone clicks one of those links, it will pass the value of startdate from that particular link to dayview in a form that you can use the PHP $_GET to grab it from the URL on dayview, what you do with it on dayview is up to you.

    Do I have that about right?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. The Following User Says Thank You to jscheuer1 For This Useful Post:

    kuau (07-19-2008)

  7. #5
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Yes, that is what I have done except in this case it is just for one day, but the day can change. I have dayview.php working already here: http://www.calendarmaui.com/php/dayview.php

    Yearview is here: http://www.calendarmaui.com/php/yearview-new.php

    What I can't seem to do is link from a day chosen on yearview-new.php to the same day on dayview.php. It always goes to today's date. I don't know what format to pass the date in. What I have tried has not worked. Even if I type dates on the URL of dayview.php the date stays the same. The code is all written, just needs a couple of tweaks. I really appreciate your take on it because it is probably more a logic problem than php. Thanks.
    Last edited by kuau; 07-19-2008 at 05:40 PM. Reason: fixed tags

  8. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Seems to work fine on:

    Code:
    http://www.calendarmaui.com/php/yearview.php
    where you pass it like so:

    Code:
    http://www.calendarmaui.com/day.php?year=2009&month=02&day=04
    Why not make the new version of the year page do it the same way?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #7
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    The live yearview.php gets its data from the old table that stores the dates as integers (eg. 20080718). I have made a new table that stores dates as dates (2008-07-19).

    With some help, I am rewritng the whole application because the code dates back to 2000. You once commented that it was "archaic" and it causes problems everytime the host upgrades the server. So that is the project -- moving to the new table before the calendar events get out of date. That yearview code works on the old dates but not the new. I figured I would have to do something different (and hopefully simpler) for the new dates. Or maybe I'm wrong and I have to do it the same way. I know way less php than you do.
    Last edited by kuau; 07-19-2008 at 05:59 PM. Reason: sp

  10. #8
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Dear John: This is done now so not to worry. Thanks very much.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •