POST into Array problem


Posted on 16th Feb 2014 07:03 pm by admin

Hi Chaps,

I have a repeat region, displaying rows of data: jobid, fromtable, translatorcharge
In each row there is an input field to enter a cost for each job 'charge'.
//INPUT - TRANSLATOR CHARGE
Code: (text) <input type="text" name="translatorcharge" id="count" class="price" value="<?php echo $row_rsInvPending['jobtranslatorcharge']; ?>"/>
I have a hidden input that collects the information for each row, before sending all the information to a script page:
//HIDDEN INPUT - INFO COLLECTOR
Code: (text) <?php
$table_name = $row_rsInvPending['fromtable'];
$item_id = $row_rsInvPending['jobid'];
?>
<input type="hidden" name="jobinvsent[]" value="<?php echo $table_name; ?>:<?php echo $item_id; ?>:<?php $_POST['translatorcharge'] ?>" />
The script page then updates the translatorcharge column in the relevant table:
//SCRIPT - TO UPDATE DATABASE
Code: (text) $allowed_tables = Array('tbl_jobs','tbl_jobtransline','tbl_jobxml'); // to prevent SQL injection
foreach($_POST['jobinvsent'] as $var) {
$arr = explode(':', $var);
if(in_array($arr[0], $allowed_tables)) {
$table = $arr[0];
$rowid = $arr[1];
$transcharge = $_POST['translatorcharge'];
if(is_numeric($rowid)) {
// run your SQL query here to update $table where row matches $rowid
$mess = $ref = $_SERVER['HTTP_REFERER']; header( 'refresh: 0; url='.$ref);
$query = sprintf("UPDATE $table SET jobtranslatorcharge='$transcharge' WHERE jobid=$rowid");
$result = mysql_query($query, $conndb2) or die(mysql_error());
}
else {
$mess = "<p>There was a problem</p>";
}
}
}
The problem is, although I'm entering different values for each row, only the last entered value is being passed to the array and therefore updating all rows with the same value.
My questions is, how can I 'individualise' each input, relating to each row?

No comments posted yet

Your Answer:

Login to answer
194 Like 50 Dislike
Previous forums Next forums
Other forums

To add a field on the screen XK02.
Hi All,

How to add an additional field in the vendor change control screen XK02.
The

Auto-populating dropdowns and multiple forms.
Here's what I have so far:

First drop down = select a state (works)
This populates the sec

Converting numbers to months
The porgram works -just need the last function(month_convert_ to convert numbers to months -thanks.

getting weird error..
okay, I'm getting an error on this particular function, something about the syntax in the mysql LIMI

Referential Integrity problem when inserting into 2 tables at same time
Hello Everyone,

Im relativity new to PHP and MySQL and i have come up against a problem. i h

IIS & NW MII on the same server
Hi,

We're weighing the possibility to run both IIS and MII (NetWeaver) on the same server

Remore client postprocessing phase getting dump SAPSQL_ARRAY_INSERT_DUPREC
Hello Expects,I have started remore client copy. Data was copied successfully. but while running pos

PHP XML extraction text
I would like to extract an xml text and have that text directly echo(print) out on my web page. Her

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

change text color with a jQuery code
Hihow can I change the text in a asp:TextBox to a different color when I start typing using jQuery?I

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash