Jump to content

andy

Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.4pixels.com

Profile Information

  • Gender
    Not Telling
  • Location
    london

andy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. anyone? ....or should I post in another forum more suited.
  2. [!--sizeo:1--][span style=\"font-size:8pt;line-height:100%\"][!--/sizeo--] [!--fonto:Verdana--][span style=\"font-family:Verdana\"][!--/fonto--] I had this 'if else' statement which calls a function depending on whether a location or a date has been chosen from drop downs. The database has a field called 'depart_time' ie which is entered as UNIXTIME and has two rows, one for outward departure, and one for inward departure (flights) ie only their chronological difference indicates which. Although my solution for the location SQL query seems to have sorted the dates error, when searching by location, I can't figure out if I can alter my dates SQL to correct the problem when searching by month/year, or whether I should be looking elsewhere. BTW I'm fairly new to php/mySQL and this is me trying to correct someone elses code. See: [a href=\"http://www.travelforthearts.co.uk/shtml/master_detail.php?type=3&month=03&year=2006\" target=\"_blank\"]http://www.travelforthearts.co.uk/shtml/ma...th=03&year=2006[/a] where the 11th comes before the 8th. [b]OLD CODE[/b] [code]     <?php                           if($_GET['location'] && $_GET['type'])                           {                               $tours = $_TOURS->get_tours_by_location($_GET['type'],$_GET['location']);                           }                               elseif($_GET['month'] && $_GET['year'])                           {                               $tours = $_TOURS->get_tours_by_date($_GET['type'],$_GET['month'],$_GET['year']);                           }                                                                                if(is_array($tours))                           {                               foreach($tours as $key => $data)                               {?>                           <tr bgcolor="#FFFFFF" class="bodycopywht">                             <td valign="top"><span class="style14"><a href="master_result.php?tid=<?php echo $data['tour_id']?>"><?php echo $data['tour_name'];?></a></span><span class="style6"><br>                               </span></td>                             <td align="center" valign="top" class="style14"><?php echo $data['day'].'/'.$data['month'].'/'.$data['year'];?></td>                           </tr>                           <?}                           }?> [/code] [b]This was the old function for location:[/b] [code] function get_tours_by_location($type,$location) {     $SQL = 'SELECT tour.*,     performances.performance_id,     venues.venue_id,     FROM_UNIXTIME(flights.depart_time,"%d") AS day,     FROM_UNIXTIME(flights.depart_time,"%m") AS month,     FROM_UNIXTIME(flights.depart_time,"%Y") AS year     FROM tour     LEFT JOIN performances ON performances.tour_id = tour.tour_id     LEFT JOIN venues on performances.venue_id = venues.venue_id     LEFT JOIN flights on flights.tour_id = tour.tour_id     WHERE tour.tour_type LIKE("%'.$type.'%") AND venues.venue_location = "'.$location.'"     GROUP BY tour.tour_id, venues.venue_location     ORDER BY flights.depart_time ASC'; [/code] ... and this for date [code] function get_tours_by_date($type,$month,$year) {     $SQL = 'SELECT tour.*,     performances.performance_id,     venues.venue_id,     FROM_UNIXTIME(flights.depart_time,"%d") AS day,     FROM_UNIXTIME(flights.depart_time,"%m") AS month,     FROM_UNIXTIME(flights.depart_time,"%Y") AS year     FROM tour     LEFT JOIN performances ON performances.tour_id = tour.tour_id     LEFT JOIN venues on performances.venue_id = venues.venue_id     LEFT JOIN flights on flights.tour_id = tour.tour_id     WHERE tour.tour_type LIKE("%'.$type.'%") AND FROM_UNIXTIME(flights.depart_time,"%m") = "'.$month.'" AND     FROM_UNIXTIME(flights.depart_time,"%Y") = "'.$year.'"     GROUP BY tour.tour_id, venues.venue_location     ORDER BY flights.depart_time ASC'; [/code] [b]unfortunately it was returning the dates on the results page in the wrong order in some searches, so I changed the if else too:[/b] [code]    <?php                           if($_GET['location'] && $_GET['type'])                           {                               $tours = $_TOURS->get_tours_by_location($_GET['type'],$_GET['location']);                           }                               elseif($_GET['month'] && $_GET['year'])                           {                               $tours = $_TOURS->get_tours_by_date($_GET['type'],$_GET['month'],$_GET['year']);                           }                                                                                                           if(is_array($tours))                           {                               foreach($tours as $key => $data)                               {?>                           <tr bgcolor="#FFFFFF" class="bodycopywht">                             <td valign="top"><span class="style14"><a href="master_result.php?tid=<?php echo $data['tour_id']?>"><?php echo $data['tour_name'];?></a></span><span class="style6"><br>                               </span></td>                             <td align="left" valign="top" class="style14"> <?php echo $data['day']?></td>                           </tr>                           <?}                           }?> [/code] [b]and the functions to:[/b] [code] function get_tours_by_location($type,$location) {     $SQL = 'SELECT tour.*,     performances.performance_id,     venues.venue_id,     DATE_FORMAT(MIN(FROM_UNIXTIME(flights.depart_time)),"%D %b %Y") AS day     FROM tour     LEFT JOIN performances ON performances.tour_id = tour.tour_id     LEFT JOIN venues on performances.venue_id = venues.venue_id     LEFT JOIN flights on flights.tour_id = tour.tour_id     WHERE tour.tour_type LIKE("%'.$type.'%") AND venues.venue_location = "'.$location.'"     GROUP BY tour.tour_id, venues.venue_location     ORDER BY flights.depart_time ASC'; [/code] and: [code] function get_tours_by_date($type,$month,$year) {     $SQL = 'SELECT tour.*,     performances.performance_id,     venues.venue_id,     DATE_FORMAT(MIN(FROM_UNIXTIME(flights.depart_time)),"%D %b %Y") AS day     FROM tour     LEFT JOIN performances ON performances.tour_id = tour.tour_id     LEFT JOIN venues on performances.venue_id = venues.venue_id     LEFT JOIN flights on flights.tour_id = tour.tour_id     WHERE tour.tour_type LIKE("%'.$type.'%")     AND FROM_UNIXTIME(flights.depart_time,"%m") = "'.$month.'"     AND FROM_UNIXTIME(flights.depart_time,"%Y") = "'.$year.'"     GROUP BY tour.tour_id, venues.venue_location     ORDER BY flights.depart_time ASC'; [/code] [b]...which as I say sorted the location searches, but not the date searches[/b] [!--sizec--][/span][!--/sizec--] [!--fontc--][/span][!--/fontc--]
  3. It may be the same problem I used to get. In your testing server window in the site setup, make sure that you have simply http://www.yoursite.com as dreamweaver puts in something like http://ftp.yoursite.com/web or whatever your directory is (htdocs, www etc) This one drove me mad for a while Andy
  4. I\'ve tried every combination of username, password, host address, dbname that you can think of in the config file with no luck. I don\'t want to have a go unless I\'m sure it is their fault.
  5. I\'ve installed phpMyAdmin on a remote server, input server ip, username and address as supplied by the hosting company and get #1045 - Access denied for user: \'signalpumps@213.171.218.20\' (Using password: YES) I assume from this that phpMYAdmin is seeing the server but having trouble with the username or password or access privaleges. Is there a way of finding out which, using telent or the sql monitor. What would be the prompts to use, as I\'m new to setting up a remote mySQL database. ps I\'ve tried a little connect php file as well with the same error [/b]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.