Page 2 of 2

Posted: Mon Aug 06, 2007 6:00 pm
by robshanks
In the database make sure the 'match_date' field is set to data type 'DATE'.

When entering match_date into the database format the date correctly.

To delete anyting prior to today (if you really want to) see earlier post with code in it.

Or instead of deleting it change the mysql query to only show matches today or in the future:

Code: Select all

//connect to server and select database
  $con = mysql_connect($servername, $username, $password);
  if (!$con)
  {
    die('Could not connect :' . mysql_error());
  }
  //select database 
  mysql_select_db($database, $con);
  //create and execute query
  $sql="SELECT * FROM ".$table." WHERE match_date>=CURDATE() ORDER BY match_date ASC";
  $result=mysql_query($sql);
  //iterate through resulting rows
  while($row=mysql_fetch_array($result))
  {
    echo $row['match_name']." ".$row['match_date']." ".$row['match_time']." ".$row['match_venue']."<br>";
  }

Posted: Mon Aug 06, 2007 6:07 pm
by mademokid
Whats this?:

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /home/www/example.com/cj/login.php:6) in /home/www/example.com/cj/login.php on line 262

Posted: Mon Aug 06, 2007 6:10 pm
by robshanks
An error . . . you have already sent a header to the browser prior to sending another header.
On line 262?

Posted: Mon Aug 06, 2007 6:51 pm
by s.dot
A lot of your questions could be easily answered via a quick search on google, or looking up examples of queries, writing them, and retrieving them, rather than having us post code examples for you.

:wink:

Posted: Tue Aug 07, 2007 4:08 am
by mademokid
Can I use variables in the insert to database function?

Posted: Tue Aug 07, 2007 6:15 am
by robshanks
Yes

Code: Select all

$sql="INSERT INTO ".$table." VALUES('".$match_name."', '".$match_date."', '".$match_time."', '".$match_venue."');";