Jump to content

file reading and inserting it into database.


abhinavsingh89

Recommended Posts

As per the client requirement he wants to read words from a file and want to insert them in database  one by one . ie a confirmation is required whether he wants to insert is or not. I have developed the thing but the problem is when i am retrieving the words it asks for all the words. i will show u wat the problem is. My main query is i want to pause the exectution until user's input.

 

<script type="text/javascript" src="jquery.js"></script> 
<script type"text/javascript"> 
function show() {
document.getElementById('form#submit').fadeIn();
alert("Abhinav");
}
$(document).ready(function(){
$("form#submit").submit(function() {
// we want to store the values from the form input box, then send via ajax below
var word    = $('#word').attr('value');
var synonym     = $('#synonym').attr('value'); 

	$.ajax({
		type: "POST",
		url: "ajax.php",
		data: "word="+ word + "&synonym=" + synonym,
		success: function(){
			$('form#submit').hide();
			//$('form#submit :input').val("");
			$('div.success').fadeIn();
		}
	});
return false;
});
});
</script> 

 

<?php 
$file=fopen("welcome.txt","r") or exit("Unable to open file!");
@$word="";
@$c="";
while (!feof($file))
{
	$c=fgetc($file);
if(strcmp($c," ")==0)
{ echo "".

"<form id='submit' method='post' name='submit' action='' >".  
        "<fieldset>  ".
            "<legend>Enter Information</legend>  ".
"            <label for='word'>Word:</label>  ".
"<input id='word' class='text' name='word' size='20' type='text' value='$word' >  ".
"            <label for='Synonym'>Synonym:</label>  ".
"<input id='synonym' class='text' name='synonym' size='20' type='text'>  ".
"            <button class='button positive' type='submit'>  Add Client </button>  ".
   " </fieldset>  ".
   " </form>  ".
"<div class='success' style='display:none;'>Client has been added.</div>  ".
"</div>";

$word="";
}
else
$word=$word.$c;
}
fclose($file);

?>

 

 

Now what i want is after user clicks add client then only next insertion box must be shown. please check the attached image to see the output. Guys pls help me over this. Thnx in advance

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.