0

i want to insert dummy data for testing my database.so i want to execute a single insert statement 1000 times.
is there any function to do so
or is there any script todo.
if so plz help me

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by rm_daniweb
0

i want to insert dummy data for testing my database.so i want to execute a single insert statement 1000 times.
is there any function to do so
or is there any script todo.
if so plz help me

With PHP you can create a loop

<?php
//connect to database first

$sql = 'INSERT INTO ...'; //change this to your query
for ($x=0;$x<1000;$x++) { 
mysql_query($sql);
}

?>

Hope that helps :)

0

i want to insert dummy data for testing my database.so i want to execute a single insert statement 1000 times.
is there any function to do so
or is there any script todo.
if so plz help me

Let's do it more realistic! :-)

My suggestion is: Create a "sample.txt" file put 1000 data separated by TAB with 3 columns inside.

or create 3 columns in MICROSOFT EXCEL FILE and save as TAB DELIMITTED.

e.g.
AA0001 TAB MR. LONELY TAB MALE
.
.
AA10000 TAB MR. LONELY TAB MALE

<form enctype="multipart/form-data" action="testing.php" method="POST">
    <blockquote>
      <table>
	        <input type="hidden" name="MAX_FILE_SIZE" value="500000" />

      <tr><td><span class="bold"> 1. Select file to load:</span></td>
          <td><input name="userfile" type="file" />

      </td></tr>
      <tr>
        <td class="bold"> 2. Put inside the database.:</td>    
          <td><input type="submit" value="Check this File" />
      </td></tr>
	  </table>
    </blockquote>
</form>


//ANOTHER FILE
//TESTING.PHP 
<?php
//Here's your submitted file temporary uploaded automatically
//on your php web server.
$thefile = $_FILES['userfile']['tmp_name'];

//OPEN BY YOUR SERVER
$fd = fopen ($thefile, "r");
while (!feof ($fd))
{
   $buffer = fgets($fd, 4096);
   $lines[] = $buffer;
}
fclose ($fd); 


foreach ($lines as $ln => $lv) {
$JText = explode("\t", $lv);

$myField1 = strlen($JText[0]); 
$myField2 = strlen($JText[1]); 
$myField3 = strlen($JText[2]); 

[PUT YOUR DATABASE INSERT CODE HERE]

}

echo "finished";

hope it will helps you friend.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.