Jump to content

Help making delete query...

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
empty_kinse

empty_kinse

    Newbie

  • Members
  • Pip
  • 7 posts
For an online reservation, any tips on making a query to delete the reservation if it isn't confirmed like 10 days before the event?
Anyone can tell me how to enhance this one?

<?php

$dbhost = 'sql204.p4o.net';

$dbuser = '';

$dbpass = '';

$conn = mysql_connect($dbhost, $dbuser, $dbpass);

if(! $conn )

{

die('Could not connect: ' . mysql_error());

}

$sql = 'DELETE FROM orders WHERE 'date' <= CURDATE()-5";


mysql_select_db('somedatabasehere');

$retval = mysql_query( $sql, $conn );

if(! $retval )

{

die('Could not delete data: ' . mysql_error());

}

echo "Deleted data successfully\n";

mysql_close($conn);

?>


#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
(untested) this should work...
DELETE FROM orders WHERE datediff(now(), `date`) > 10

__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
empty_kinse

empty_kinse

    Newbie

  • Members
  • Pip
  • 7 posts
Thanks a lot for the help Orjan.

Say, how can I make an output of a pie chart or any kind of chart showing the statistics of what item is the most ordered and/or the least ordered one..?Any idea?

#4
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
easiest way would be to use google chart api, Google Chart Tools / Image Charts (aka Chart API) - Google Code
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall