CSV and random from elements
- From: Michel Beaussart <michel@xxxxxxxxxxxxxx>
- Date: Thu, 27 Oct 2005 22:27:18 -0700
Hi all,
OK let me try to explain this (better):
I have a form created by the following:
<?php
$array = array("block1.html","block2.html","block3.html");
shuffle($array);
$show = implode(",",$array);
include ("formopen.html"); //contains html tags and form tag
include("$array[0]");// form part I
include("$array[1]");//form part II
include("$array[2]");//form part III
include ("formclose.html"); // contains submit button ...
?>
When the submit button is clicked,the form handler is as follow:
<?php
$handle = fopen ("data/data.csv",'r'); // open file
$data = fgetcsv($handle, 1000, ","); // get csv
$data_fields = explode (",",$data); // create array
fclose($handle); // close file
// write data in a csv file
$fp = fopen("data/data.csv", 'a+');
foreach ($_POST as $k => $v)
{
fwrite ($fp, "$v,");
;
}
fclose($fp);
?>The problem is that I have a header in the CSV file (that I picked up into $data) BUT .. I have no idea how to put the form elements value into the proper column of the csv file (NOTE: each column of the csv file corresponds to an elements name)
So that
HTML Code:
<input type='text' name='rded1' size='40' maxlength='30'>
rded1 is also the name of column in the csv file (say position 4). BUT rded1 in $_POST might be position 1 or 6 or 15 depending the order determined by the randomization..
PLEASE HELP ME FINISH THIS >>>>> IT DRIVES ME INSANE !!!!!!!!!
.
- Prev by Date: require_once
- Next by Date: Get PHPNUKE Hosting
- Previous by thread: require_once
- Next by thread: Get PHPNUKE Hosting
- Index(es):
Loading