Best Language to do this in

Associate
Joined
19 Jul 2006
Posts
1,847
I know I can do this in excell but wanted to make things more exciting. So i have knocked up this form.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="">
  <p>P.Code 
    <input name="Pcode" type="text" id="Pcode">
</p>
  <p>FirstName 
    <input name="Firstname" type="text" id="Firstname">
    </p>
  <p>LastName 
    <input name="Lastname" type="text" id="Lastname">
</p>
  <p>D.O.B 
    <input name="DOB" type="text" id="DOB">
    </p>
  <p>Course 
    <input name="Course" type="text" id="Course">
    </p>
  <p>Group 
    <input name="Group" type="text" id="Group">
    </p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>
</body>
</html>

From the information there i want to create a csv file.
in the form
Pcode, DOB,Firstname,Lastname,email([email protected]),Pcode,course,group,1.

what would be the language of choise here? php? asp? or should I dabble at java :S.

i want this form to add one person to the csv file. I would like when submit is pressed for the information to be wrote and then the form displayed again with everything blank but if possible the course and group to display what was last entered.
 
yes, but bonus points for writing the PHP front end code to whip the db rows back out as csv and extra bonus points for making the output cutomisable etc..
 
Right can some one prod me in the right direction.

I have a mysql database with the following in,
Id number, DOB, First name, Surname, CCode.

The CCode is the class code, as its just an inported file there are records with the same CCode in.

I would like to create a PHP page that creates a drop down menu that is populated by the results in the CCode column dynamically, with a submit butten that when clicked produces a csv file for that CCode in the form
PHP:
<?php
mysql_select_db("db", $link);
$sql="SELECT Course FROM table"; 
$result=mysql_query($sql); 

$options=""; 

while ($row=mysql_fetch_array($result)) { 

    $course=$row["Course"]; 
     
   $options.="<OPTION VALUE=\"$Course\">".$Course.'</option>';

} 
?> 
<form action="blank" method="get" name="Select">
<SELECT NAME=Course>
<OPTION VALUE=0>Choose
<?php echo "$options" ?>
</SELECT> 
</form><br />

<?php mysql_close($link); ?>
That code does not throw any errors and produces a drop down list but theres no values in it??


Idnumber, DOB, Firstname, Lastname, (email) which is [[email protected]], Idnumber, [blank space] , CCode, 1.

can this be done?
what kind of logic am i looking at for the output, would this be straight to csv output or would i be creating a new db then outputting to csv
 
Last edited:
Well for a start, you have Course and course which won't help things.

Secondly, I am not familiar with the syntax $options.= blah blah... Does that dot after options do something special? Surely you need to encapsulate all this in a loop and read it out of the DB, or options will only ever be the last element selected.
 
Im now using this code
PHP:
<form action="Display.php" method="post" name="Course Select" target="_self"><?php
mysql_select_db("misstudents", $link);

 
$query="SELECT DISTINCT Course FROM misimport";


$result = mysql_query ($query);
echo "<select name=category value=''></option>";

while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[Course]>$nt[Course]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?> 

<input name="Submit" type="submit" value="Submit" /></form>

<?php mysql_close($link); ?>

Which works :) in the drop down box i get
ABB121 Random Course 1 ect
But when i get to the Display.php page
PHP:
<?php echo $_POST["category"];?>
Returns a value of ABB121 and nothing after the spaces is there anything i can do about this?
 
Hi,

Without " or ' around the value=x it will cut off after any spaces.
Change
Code:
echo "<option value=$nt[Course]">$nt[Course]</option>";

To:

Code:
?>
<option value="$nt[Course]">$nt[Course]</option>
<?php

I don't really do php but that should solve it:)
 
Back
Top Bottom