?
Solved

Inserting updated values in mysql database

Posted on 2012-12-20
5
Medium Priority
?
364 Views
Last Modified: 2012-12-21
Hello Experts,

I am displaying the query results like below on php page....
From mysql there were two rows resulted which is displaying as per the code below...
echo "<tr class=\"d" . ($i & 1) . "\">
                        <td><input class=textboxa type=text style=\"font-style: Italic;font-weight: bold;\" value=\"$i\" /><br/></td>
                        <td><input name=test_$i class=textboxc type=text style=\"font-style: Italic;font-weight: bold;\" value=\"" . $row['Delivery'] . "\" title=Delivery /><br/></td>
                        <td><input name=subtest_$i class=textboxc type=text style=\"font-style: Italic;font-weight: bold;\" value=\"" . $row['quality'] . "\" title=quality /><br/></td></tr>";

Open in new window


If user updates the value in one of the input type text...i would like to updated that value in database.

Can you suggest how to updates the values in mysql where $_POST['test'] this test will might be test_1 or test_2 and so on...

Thanks,
Shail
0
Comment
Question by:ShaileshShinde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Assisted Solution

by:sivagnanam chandrakanth
sivagnanam chandrakanth earned 268 total points
ID: 38712287
Rather than keeping the variable as test_$i, keep it as keep[$i] as array.. iN that way your variable name will be same and key alone will change..

So in submit handler you can handle as

for($i=0;$i<count($_POST['test']);$i++){
$_POST['test'][$i] will have the value for you
}
0
 
LVL 1

Author Comment

by:ShaileshShinde
ID: 38712505
Hello Expert,

In php i kept name="test[]" and in the POST

for($i=0;$i<count($_POST['test']);$i++){
$test = $_POST['test'][$i] ;
echo "$test";
}
However, this is throwing an error message as "Notice: Undefined index: test in info_r2b.php on line 1"

Can you suggest what's gone wrong in this?

Thanks,
Shail
0
 
LVL 11

Assisted Solution

by:mcnute
mcnute earned 132 total points
ID: 38712558
Hello Shail, you must give a name test[] to all of your inputs in order to make ShaileshShindes solution to work.

echo "<tr class=\"d" . ($i & 1) . "\">
                        <td><input class=textboxa type=text style=\"font-style: Italic;font-weight: bold;\" value=\"$i\" /><br/></td>
                        <td><input name=test[] class=textboxc type=text style=\"font-style: Italic;font-weight: bold;\" value=\"" . $row['Delivery'] . "\" title=Delivery /><br/></td>
                        <td><input name=test[] class=textboxc type=text style=\"font-style: Italic;font-weight: bold;\" value=\"" . $row['quality'] . "\" title=quality /><br/></td></tr>";

Open in new window



Althought I've seen this tequnique only with checkboxes.
0
 
LVL 12

Accepted Solution

by:
sivagnanam chandrakanth earned 268 total points
ID: 38712564
@ mcnute is right, except it will for all input types
0
 
LVL 1

Author Closing Comment

by:ShaileshShinde
ID: 38712578
Thanks Experts
0

Featured Post

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This article discusses how to implement server side field validation and display customized error messages to the client.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question