homepage Welcome to WebmasterWorld Guest from 54.161.192.130
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Emptying A Table
dkin

10+ Year Member



 
Msg#: 11720 posted 4:35 pm on Feb 12, 2006 (gmt 0)

How do you empty a table in mysql using php?

 

Anyango

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 11720 posted 5:05 pm on Feb 12, 2006 (gmt 0)

mysql_query("truncate table TABLENAME");

newb

5+ Year Member



 
Msg#: 11720 posted 10:48 pm on Feb 12, 2006 (gmt 0)

<?php

$connection = mysql_connect('localhost', 'user', 'pass');

mysql_select_db('db_name);

$sql = "TRUNCATE TABLE `table_name`";

mysql_query($sql);

mysql_close($connection);

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 11720 posted 6:13 pm on Feb 13, 2006 (gmt 0)

or just

delete from tablename

that deletes all rows

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved