|
-
Steps to Insert txt data into database:
If you look at the countryCode.txt file, you can realize that to put this type of huge data into a database table is quite a tough time taking job if you do it manually. However, in this discussion I am going through steps where the PHP code will do this job in one click.
Step 1:
Place the text file into the www folder. Make sure that each line data holds the code then the sign and in last the name of the countries (example: countryCode:countryName). In PHP, this entire data will place in an array and each line will count one array number. The “:” sign is the separator of code and the name of the entire data.
Step 2:
To do the backend operation happen, we have to make a front-end html page from where we can put a database table name and call the php to run. I am going to give you a simple example to do this with a minimum need of an input text field and a create button in the html page.
HTML Code:
<html>
<head>
<title>:: EMI Application :: Create Table</title>
</head>
<body style="background:#E4E4E4; margin:auto;">
<script Language="JavaScript">
<!--
function Validator(){
if (createTable.name.value == ""){
alert("Enter Table Name.");
createTable.name.focus();
return (false);
}
return (true);
}
-->
</script>
<div style="background:#990000; padding:5px 0px 10px 10px;">
<form style="font-family:Arial, Helvetica, sans-serif; color:#999999;" name="createTable" method="POST" action="countryCode.php" onsubmit="return Validator()">Database Table Name:<br><input type="text"size="29"style="font-family:Arial, Helvetica, sans-serif;background:#FFFFCC;color:#996666;" maxLength="100" name="name">
<input type="submit"style="font-family:Arial, Helvetica, sans-serif;font-size:12;" value="Create">
</form>
</div>
<div style="padding:2px 10px 10px 10px;font-family:Arial, Helvetica, sans-serif;color:#999999;font-size:11;"><strong>"Collect All" to Make a Professional Mobile Application in Flash Lite 1.1 Enabled Devices. EMI Application.</strong> © - 2010-2011 <strong> MarlöPax.</strong> All rights reserved.</div>
</body>
</html>
The above HTML code will display an input text field and a create button with a JavaScript text field validation and some CSS style decoration.
Step 3:
Make a new PHP file “creatTable.php” for this operation.
continue... Step 3..........
marlopax
Subha Nabo Barsha (Bengali New Year 1417)
Thursday, April 15, 2010
Last edited by marlopax; 04-14-2010 at 03:14 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|