close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Php dates and recordsets

Thread began 2/25/2012 3:55 pm by newimage96814918 | Last modified 2/27/2012 9:51 am by Jason Byrnes | 4527 views | 10 replies |

newimage96814918

Php dates and recordsets

Here i am again with another little quandry. I have two recordsets on the page with events in repeat regions, I am trying to filter them by date the past shows to show ones date past and upcoming to show where date > greater than, I set the recorsets in dreamwaever and variables to the date and test all seem s well. I go to wiew page I get this error:
Fatal error: Can't use function return value in write context in C:\wamp\www\Crossroads\FeaturedExhibits.php on line 37
So I did a bit of research and supposable to do with the syntax on the isset function, I mod it around a bit and that error goes away but I get major warning in haed of my page and only one of my recorsets show up. I have data for both the past and future shows.
I'm sure I just struggling with this date() stuff and php cause I'ts new to me and I cannot for the life of me get it correct.
I am including to page If you would'nt mind taking a look?

Tracy

Attached Files
FeaturedExhibits.zip
Sign in to reply to this post

newimage96814918

I also tried taking the variables out and using this code in the recordsets:

SELECT featured_shows.feature_id, featured_shows.event_id, featured_shows.feat_title, calendar_event.id, calendar_event.date_start FROM featured_shows, calendar_event WHERE DATE_FORMAT(calendar_event.date_start, '%Y-%m-%d') >= DATE_FORMAT(now(),'%Y-%m-%d')

on one and

SELECT featured_shows.feature_id, featured_shows.event_id, featured_shows.feat_title, calendar_event.id, calendar_event.date_start FROM featured_shows, calendar_event WHERE DATE_FORMAT(calendar_event.date_start, '%Y-%m-%d') <= DATE_FORMAT(now(),'%Y-%m-%d')

on the other then I get no errors but the where statement is'nt working I am attaching the page as it now sits. and here is a link to view what it's doing live:

FeaturedExhibits.php

Thanks!

Tracy

Attached Files
newexhibitpage.zip
Sign in to reply to this post

Jason ByrnesWebAssist

to help troubleshoot this, I'll need some additional info.

on your page, change the code for displaying the past shows:

php:
<h2>Past shows</h2>
              <?php do { ?>
                <table width="100%" border="0">
                  <tr>
                    <td><a href="FeaturedExhibitsDetail.php?event_id=<?php echo $row_rsFeatListpast['event_id']; ?>"><?php echo $row_rsFeatListpast['feat_title']; ?></a></td>
                  </tr>
              </table>
                <?php } while ($row_rsFeatListpast mysql_fetch_assoc($rsFeatListpast)); ?>




to:

php:
<h2>Past shows: <?php echo("SQL: ".$query_rsFeatListpast); ?></h2>
              <?php do { ?>
                <table width="100%" border="0">
                  <tr>
                    <td><a href="FeaturedExhibitsDetail.php?event_id=<?php echo $row_rsFeatListpast['event_id']; ?>"><?php echo $row_rsFeatListpast['feat_title']; ?>||<?php echo $row_rsFeatListpast['calendar_event.date_start']; ?></a>calendar_event.date_start</td>
                  </tr>
              </table>
                <?php } while ($row_rsFeatListpast mysql_fetch_assoc($rsFeatListpast)); ?>




and the code for showing upcoming shows:

php:
<h2>upcoming shows</h2>
              <?php do { ?>
              <table width="100%" border="0">
                  <tr>
                    <td><a href="FeaturedExhibitsDetail.php?event_id=<?php echo $row_rsFeatListup['event_id']; ?>"><?php echo $row_rsFeatListup['feat_title']; ?></a></td>
                  </tr>
              </table>
                <?php } while ($row_rsFeatListup mysql_fetch_assoc($rsFeatListup)); ?>



to:

php:
<h2>upcoming shows: <?php echo("SQL: ".$query_rsFeatListup); ?></h2>
              <?php do { ?>
              <table width="100%" border="0">
                  <tr>
                    <td><a href="FeaturedExhibitsDetail.php?event_id=<?php echo $row_rsFeatListup['event_id']; ?>"><?php echo $row_rsFeatListup['feat_title']; ?>||<?php echo $row_rsFeatListup['calendar_event.date_start']; ?></a></td>
                  </tr>
              </table>
                <?php } while ($row_rsFeatListup mysql_fetch_assoc($rsFeatListup)); ?>




this will show the dates for the shows and the SQL that is executed at run time for the recordsets.

Sign in to reply to this post

newimage96814918

Cool Jason!
The page is now on the server!

Tracy

Sign in to reply to this post

Jason ByrnesWebAssist

what is the structure of the FEATURED_SHOWS and CALENDAR_EVENT tables?

I think you need to be using a join query:
sql_join.asp

Sign in to reply to this post

newimage96814918

the calendar event table has a primary key column called "id" in the featured shows table I have a column event_id which I'm trying to relate to that.

Sign in to reply to this post

Jason ByrnesWebAssist

ok, so the select / from portion of your query:

SELECT featured_shows.feature_id, featured_shows.event_id, featured_shows.feat_title, calendar_event.id, calendar_event.date_start 
FROM featured_shows, calendar_event



needs to be changed to use inner join:

SELECT featured_shows.feature_id, featured_shows.event_id, featured_shows.feat_title, calendar_event.id, calendar_event.date_start 
FROM featured_shows
INNER JOIN calendar_event
ON featured_shows.event_id = calendar_event.id
Sign in to reply to this post

newimage96814918

I probably would'nt even need the date_format option like this then:
SELECT featured_shows.feature_id, featured_shows.event_id, featured_shows.feat_title, calendar_event.id, calendar_event.date_start FROM featured_shows, calendar_event WHERE DATE_FORMAT(calendar_event.date_start, '%Y-%m-%d') >= DATE_FORMAT(now(),'%Y-%m-%d')

If I was to use a join could I just use Date()?

I'm just not sure How I would join those?

You beat me to the post I'll try what you suggest and get back to you.

Tracy

Sign in to reply to this post

Jason ByrnesWebAssist

no, you would still need the where clause at the end of the SELECT .. FROM ... INNER JOIN... ON.. statement i provided. so the full sql statement would be:


SELECT featured_shows.feature_id, featured_shows.event_id, featured_shows.feat_title, calendar_event.id, calendar_event.date_start 
FROM featured_shows
INNER JOIN calendar_event
ON featured_shows.event_id = calendar_event.id
WHERE DATE_FORMAT(calendar_event.date_start, '%Y-%m-%d') >= DATE_FORMAT(now(),'%Y-%m-%d')
Sign in to reply to this post

newimage96814918

That did the trick thanks Jason!
Look like I'm gonna have to rewrite a few of my query's this way now, thanks for getting me pointed in the right direction!

Tracy

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...