PHP and mySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
robshanks
Forum Commoner
Posts: 32
Joined: Sun Aug 05, 2007 9:27 pm
Location: Hull, UK

Post 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>";
  }
mademokid
Forum Commoner
Posts: 25
Joined: Tue Jul 10, 2007 11:10 am

Post 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
User avatar
robshanks
Forum Commoner
Posts: 32
Joined: Sun Aug 05, 2007 9:27 pm
Location: Hull, UK

Post by robshanks »

An error . . . you have already sent a header to the browser prior to sending another header.
On line 262?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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:
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
mademokid
Forum Commoner
Posts: 25
Joined: Tue Jul 10, 2007 11:10 am

Post by mademokid »

Can I use variables in the insert to database function?
User avatar
robshanks
Forum Commoner
Posts: 32
Joined: Sun Aug 05, 2007 9:27 pm
Location: Hull, UK

Post by robshanks »

Yes

Code: Select all

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