amazer kombi pilot
3,187 posts · joined Aug 2002 ·
SIMPLE SQL
This is for my php assignment at uni. I dont know databases. It's probably going to be very embarrassing but screw you all, it works, I just want it prettier 😉 oookkkk.... The table holds a list of temperatures on given days for any given city. The html page takes the name of a city, a start and end date, and then a response page is sent back with the temperatures for the city between those dates.
CREATE TABLE TEMPS
(
a_city varchar(32) NOT NULL,
a_date varchar(10) NOT NULL,
a_temp integer NOT NULL,
a_strdate integer NOT NULL
);
that is the city name, the date in 02/05/2003 format, the date in 20030502 format and the temperature in deg C.
the php (pretty hopeless programming):
$stmt = OCIParse($conn,"SELECT * FROM TEMPS WHERE a_city = '$city' AND a_strdate > $start AND a_strdate < $end" );
OCIExecute($stmt);
print"Data for<br>$city";
print"<table border=1><tr><td>DATE</td><td>TEMP</td></tr>";
while(OCIFetchInto($stmt, $result)){
print"<TR><TD>$result[1]</TD>";
print"<TD>$result[2]</TD></TR>";
}
What I want to do is print the table out in chronological order.
There must be an easy way yes? Without putting all the data into an array?something in the select statement?
Thankyou all in anticipation. But dont wait too long you only got till midnight sunday to get me through it. "We're only 1/3 the way through. :P
cheers :beer