|
Posted by steve on 09/29/64 11:30
| Thank you very much for your input.
np.
| Your suggestion for the last column has been implemented.
hope that cleans things up for you.
| As for my csv file the problem is still existing as I do not know where
| to begin.
let's try now.
| I have a specific header in the csv file. Each columns name corresponds
| to a form element's name.
| So that:
|
| <input type='text' name='rded1' size='40' maxlength='30'>
|
| has a column named rded1
first off. i assume that all your .html pages you are randomly including
have different columns/input names. i'm also recommending you create a csv
for each being submitted so they can change independently. now, one thing
they all have in common is that they are included within the same php
script. so in that script, you could put something like...
$columns['htmlA'][] = 'rded1';
$columns['htmlA'][] = 'rded2';
$columns['htmlB'][] = 'foo';
$columns['htmlC'][] = 'bar';
in each of you html included pages, simply name the submit button with a
specific name:
in html include 1...
<input type=submit name=submitA>
in html include 2...
<input type=submit name=submitB>
in html include 3...
<input type=submit name=submitB>
or whatever...
| BUT how do I specify that (Pcode):
now back in your main php script, find out which did the submitting...if
any.
$submitSource = isset($_POST['submitA']) ? 'a' :
isset($_POST['submitB']) ? 'b' :
isset($_POST['submitC']) ? 'c' :
'';
now...
// define them in order you want them written
$columns = array();
switch ($submitSource)
{
case 'a' : $columns[] = 'rded1';
$columns[] = 'rded1';
break;
case 'b' : $columns[] = 'foo';
break;
case 'c' : $columns[] = 'bar;
break;
}
finally...
$record = array();
foreach ($columns as $column)
{
$record[] = $_POST[$column];
}
$fp = fopen('data/' . $submitSource . '.csv', 'a+');
fwrite('"' . implode('", "', $record) . '"');
fclose($fp);
i did this without checking for syntax and such, so you may need to clean it
up.
hth,
me
[Back to original message]
|