Chaos Dragon Posted September 8, 2009 Share Posted September 8, 2009 Hello Everyone, I am new to PHP and MySQL. I have been working with HTML and CSS mostly. I have been working with PHP and MySQL for about 4 to 5 months now. I have gotten the understanding on how a table should be created and how to install them through phpMyAdmin and through a simple PHP script, but what I am trying to do is put delays in my MySQL install script. Right now I am using the sleep() function to do this. It is working just fine, but what I would like to do is also show a countdown of each. So for example if mysql_query (" CREATE TABLE ".$TABLE_PREFIX."ban ( bid int(11) unsigned NOT NULL auto_increment, type tinyint(4) unsigned NOT NULL default '0', value varchar(250) NOT NULL default '0', PRIMARY KEY (bid), KEY type (type,value(1)) )") or die(mysql_error()); sleep(3); is inserted there will be a three second delay before the next table is created. What I would like to do it when the 3 second delay comes there will be a counter that counts down the seconds. So when table ban is created there will be a 3 second timer that will show before the next table is created. This way it does not install everything to fast and possibly overload the DB. There will be a lot of tables and inserts to install. I have been working with it and debugging and testing. I got an e-mail from my host asking me to either slow the install down or add time delays in between table creations. I guess it is overloading the DB a little and I am also on a shared environment which may be part of it. I did let them know the reason for the dropping and reinstalling is due to testing and debugging. They understand, but they would rather I do that for now. I am using PHP 5 and MySQL 5.0.67-community and the code snippet you see above is pretty much what the whole script will look like with all codes in place. So if there is any one out there that can either get me on the right track for the delay with counter or send me to the right place that may show me how to do it. I have Searched through Google, but no luck I also searched here for a possible topic on this subject, but no luck again. So I'll try posting. Thank You in advance. Quote Link to comment https://forums.phpfreaks.com/topic/173575-solved-delay-in-between-table-creation-and-table-inserts/ Share on other sites More sharing options...
Chaos Dragon Posted September 8, 2009 Author Share Posted September 8, 2009 Ok I'll try this. Maybe I asked the question wrong or i just wasn't clear on what I was trying to explain. If that is the case I do apologize for this. I am new to asking for help on forums. What I am trying to accomplish here is to take the sleep() function and use it to display a little counter. (EX. The table will be Created in: then count down from what the parameter is, let's say 5. So it counts down from 5 to 0.) The Script that this DB goes with has nothing to this effect I can use as an example to do this. I looked into W3Schools deeper, but found nothing. I searched here and nothing. Googled Nothing thought I found something a few times but not what I was needing.... or is there another function I can use to achieve the same results. Again I would like to apologize if I posted in the wrong place, or I asked the question wrong, or what ever it may be. echo'<table style="border: 1px solid white" rules="all"> <tr> <td align="center"> <font style="color: red;font-weight: bold">Creating table: ';echo $TABLE_PREFIX . "ban";echo'</font></td><td align="center">'; sleep(3); mysql_query (" CREATE TABLE ".$TABLE_PREFIX."ban ( bid int(11) unsigned NOT NULL auto_increment, type tinyint(4) unsigned NOT NULL default '0', value varchar(250) NOT NULL default '0', PRIMARY KEY (bid), KEY type (type,value(1)) )") or die(mysql_error()); echo' <font style="color: green;font-weight: bold">Table Creation Complete</font></td></tr> <tr><td align="center"> <font style="color: red;font-weight: bold">Creating table: '; echo $TABLE_PREFIX . "config";echo'</font></td><td align="center">'; sleep(3); mysql_query (" CREATE TABLE ".$TABLE_PREFIX."config ( vid int(11) unsigned NOT NULL auto_increment, variable varchar(30) NOT NULL default '0', value text NOT NULL, req tinyint(4) unsigned NOT NULL default '1', name varchar(40) NOT NULL default '0', PRIMARY KEY (vid), KEY ivariable (variable) )") or die(mysql_error()); echo' <font style="color: green;font-weight: bold">Table Creation Complete</font></td></tr> <tr><td align="center"> <font style="color: red;font-weight: bold">Creating table: '; echo $TABLE_PREFIX . "posts";echo'</font></td><td>'; sleep(3); mysql_query (" CREATE TABLE ".$TABLE_PREFIX."posts ( pid int(11) unsigned NOT NULL auto_increment, date int(11) unsigned NOT NULL default '0', text text NOT NULL, poster varchar(240) NOT NULL default '', location varchar(130) NOT NULL default '', posteremail varchar(240) NOT NULL default '', msn varchar(25) NOT NULL default '', aim varchar(70) NOT NULL default '', yim varchar(25) NOT NULL default '', homepage varchar(240) NOT NULL default '', icq int(11) unsigned default NULL, useragent varchar(240) NOT NULL default '', gender char(1) NOT NULL default '', age varchar(40) NOT NULL default '', validated tinyint(1) unsigned NOT NULL default '1', c_field_1 varchar(100) NOT NULL default '', c_field_2 varchar(100) NOT NULL default '', c_field_3 varchar(100) NOT NULL default '', c_field_4 varchar(100) NOT NULL default '', c_field_5 varchar(100) NOT NULL default '', pip varchar(16) NOT NULL default '0', PRIMARY KEY (pid) )") or die(mysql_error()); Creating Table: Table Prefix_ban (three seconds go by table created the displays) Table Creation Complete And so on. Would like a display of the seconds also to show. Thank You! Marco P.S. It is a script for a guestbook that I am using to learn PHP and MySQL it is a Script a late friend of mine wrote. So I am basically going of that for examples I can pull and use separately to learn how they work and what I can do with it. Quote Link to comment https://forums.phpfreaks.com/topic/173575-solved-delay-in-between-table-creation-and-table-inserts/#findComment-915085 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.