I have a small data base that will be updated with new information ever 24 hours but before the update I'd like to clear the existing database, is there a simple way to do this?
I'm using mysql and the database is called top10
Thanks
i dont know about the whole of a database but to clear a table you will wanna use something like this
TRUNCATE table_name
table_name
I just made a loop for it in the end, could nt find away to use the above in my admin.php script..
include ('dbconnect.php'); $query_items = "SELECT * FROM top10 ORDER BY ID"; $items = mysql_query($query_items) or die(mysql_error()); $row_items = mysql_fetch_assoc($items); do { $ID = $row_items['ID']; $sql = "DELETE FROM top10 WHERE ID=$ID"; if ($result = mysql_query($sql)) { } else { die(mysql_error()); } } while ($row_items = mysql_fetch_assoc($items));
you do realise all that is pointless because all you need is
<? include ('dbconnect.php'); $sql = "TRUNCATE `top10`"; $query = mysql_query($sql) or die (mysql_error()); ?>
which would make the page load faster, and is easier to remember
I know now which is why I asked 🙂
Thanks for you help