Solved

Inserting updated values in mysql database

Posted on 2012-12-20
5
345 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 67 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 33 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 67 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress and Wufoo 1 39
warning code: class php incomplete message 6 37
Make login page safer 3 34
What is define("__APPROOT__", __DIR__); 6 32
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 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