PDA

View Full Version : Setting a Query



justjay
10-24-2003, 10:02 AM
OK thought I had a really great IDEA here to get the SERVER and MySQL to work for ME instead of the other way around so I tried this...



$query_Flights ="UPDATE Flights SET Valid = 'NO' WHERE UNIX_TIMESTAMP(DropDate) <= UNIX_TIMESTAMP();";
$query_Flights = "SELECT * FROM Flights ORDER BY Flights.Valid, Flights.Destination, Flights.DepartureDate, Flights.InputDate ASC";
$Flights = mysql_query($query_Flights, $connect) or die(mysql_error());
$row_Flights = mysql_fetch_assoc($Flights);
$totalRows_Flights = mysql_num_rows($Flights);


The important bit is in bold - I wanted to change that field automatically so that on the MASTER list it would fall under the NO section as you can see I am assembling the order by VALID first so we can see the ones that the CLIENTS are not seeing first - then we decide if we are dropping them or not (it may be that they need to be updated with new data)

However nothing changes when I call the page - I did try the Query in the MySQL box to ensure that my Syntax was correct and it worked!

IDEAS or suggestions?

justjay
10-24-2003, 10:51 AM
I figured it out...had to seperate queries...will post the code when I have a bit more time -- right now I have have to go and make some changes to some web pages!

justjay
10-24-2003, 11:12 AM
Ok this is what I did...


//Auto set Valid to NO
mysql_select_db($database_connect, $connect);
$query_Cruise = "UPDATE Cruise SET Valid = 'NO' WHERE UNIX_TIMESTAMP(DropDate) <= UNIX_TIMESTAMP();";
$Cruise = mysql_query($query_Cruise, $connect) or die(mysql_error());
//Auto set Valid to Yes
mysql_select_db($database_connect, $connect);
$query_Cruise = "UPDATE Cruise SET Valid = 'YES' WHERE UNIX_TIMESTAMP(DropDate) >= UNIX_TIMESTAMP();";
$Cruise = mysql_query($query_Cruise, $connect) or die(mysql_error());
//Recordset to Display ALL Data
mysql_select_db($database_connect, $connect);
$query_Cruise = "SELECT * FROM Cruise ORDER BY Cruise.Valid, Cruise.CruiseDestination, Cruise.SailingDate, Cruise.PricedFrom, Cruise.InputDate, Cruise.DropDate ASC";
$Cruise = mysql_query($query_Cruise, $connect) or die(mysql_error());
$row_Cruise = mysql_fetch_assoc($Cruise);
$totalRows_Cruise = mysql_num_rows($Cruise);


:-)