
October 13th, 2009, 03:44 PM
|
|
Contributing User
|
|
Join Date: Jul 2009
Posts: 83
Time spent in forums: 13 h 53 m 8 sec
Reputation Power: 1
|
|
Code:
<html>
<body>
<form method="post" action="text.php">
<br/>
<br/>
<p>
Select a file:<input type="file" name="dataf" size="40">
<br/></p>
<p>
<input type="submit" value="Import"></p>
<br/>
<br/>
<?php
$host = "localhost";
$username = "db username";
$password = "db password";
$dn_name = "db name";
//database Connection to populate the dropdown box
$connect = mysql_connect($host, $username, $password);
mysql_select_db($db_name);
$sql="SELECT course FROM Clients";
$result=mysql_query($sql);
$options="";
while($row=mysql_fetch_array($result)) {
$course=$row["course"];
$options.="<OPTION VALUE=\"$course\">";
}
?>
<p>
Select Course:
<select name="course">
<OPTION VALUE=0><?=$options?>
</select>
</p>
<p>
Date:<input type="text" name="date"><a href="#" onClick="setYears(1947, 2020);
showCalender(this, 'date');">
<img src="calender.png">
</a>
</p>
<p>
<input type="submit" value="Send">
</p>
</form>
</body>
</html>
The above is html code.
PHP Code:
<?php
$csv = glob("/*.csv");
$data = array();
foreach($csv as $file ){
$data = array_merge($data, file($file));
}
foreach ($data as $line){
$num = explode(",", $line);
}
//infodb is dbname and StoreTable is table name.
//to insert the values of php form into database with Unique ID
$scourse = $_POST['selectcourse'];
mysql_connect("localhost", "infodb", "password") or die("Unable to connect");
mysql_select_db("info");
$query="INSERT INTO StoreTable(ID, selectcourse) VALUES ('NULL','".$scourse."')";
?>
The php thing is just an idea of doing this way.
Thanks
|