473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Updating PHP Generated Form

onlymars
Hi all fellows, i am in a messed up situation right now, i have a table in mysql containing different currencies and their values, i have generated a form in php which display them both, but now i want to update them. my mysql database has 2 fields 1. curr_name 2. curr_amount, i am reading both of them in a text box so that it can be updated, my php code here.. [php]echo "<table width='100%'>";
while($curr=mysql_fetch_array($result2))
{
$a=$curr['curr_name'];

echo "<tr><td>";

echo "<input name='" . $curr['curr_name'] . "' value='" . strtoupper($a) . "'>";

echo "<td><input name='" . $curr['curr_name'] . "' value='" . $curr['curr_amount'] . "'>";
echo "<td><a href='delete.php?currency=" . $curr['curr_name'] . "' >Delete Record</a>";

}
echo "</table>";[/php]as u would have noticed i am also deleting the record by sending information by GET method, which is working, but i need to update the values in the text fields.
this form has also function of inserting new records, so it has update, insert and delete opeartions. only update is messed up.
Plz help me out.
Mar 30 '08 #1
7 1585
ronverdonk
4,258 Expert 4TB
Welcome to The Scripts!

Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Mar 30 '08 #2
ronverdonk
4,258 Expert 4TB
You only showed some form building code for the DELETE record. What about the code for the update/insert.
And where is the scipt that handles the insert and/or update request?

And show that code within the appropriate code tags, as requested before.

Ronald
Mar 30 '08 #3
Sorry man i am a newcomer to this forum thats y didn't knew the tags. i am reaind the records from mysql but am not sure how to catch them on my update page, the delete and insert new records page's are easy but i am stuck in update page cause all the textboxes will have the same name making it a aray of values, so how do i catch them on next page and update the values. Thanx
Mar 31 '08 #4
ronverdonk
4,258 Expert 4TB
You want us to guess what your code looks like? Or are you looking for a freebie?
You show (part of) a script that works ok to you but you don't want to show the other code, the one that the problem is about.

When you seek help, but do not want to show any code for the form and the update script you have this far, we cannot help you in any way.

Ronald
Mar 31 '08 #5
dlite922
1,584 Expert 1GB
Sorry man i am a newcomer to this forum thats y didn't knew the tags. i am reaind the records from mysql but am not sure how to catch them on my update page, the delete and insert new records page's are easy but i am stuck in update page cause all the textboxes will have the same name making it a aray of values, so how do i catch them on next page and update the values. Thanx
An update is usually done by the primary key (or Unique field) of the table.

the key (if not relevant for the user) is usually in a hidden input field.

To make an update, your SQL would look something like this:
Expand|Select|Wrap|Line Numbers
  1. UPDATE tableName SET fieldName = " . $variable . "...  WHERE primaryKeyField = " . $value; 
I don't know what your table looks like, but if you post it we can help you make an update SQL statement if you can't figure it out.

good luck,

DM
Mar 31 '08 #6
ok folks i am hell sorry to all u, i dont know how to get u people understand my problem, here is the code
Expand|Select|Wrap|Line Numbers
  1.    $checked= $_POST['check'];
  2.  
  3.     $ids = (is_array($checked)) ? implode(',', $checked) : $checked;
  4.     mysql_query ("UPDATE currency SET curr_amount IN($ids)");
  5.  
this page recieves the array of values but is unable to update the table, if u fellows dont undertand it yet again then plz dont mind i will send u both pages code in some time.
thanx for ur patience
Mar 31 '08 #7
helloo guys i have the code now with me, sorry for being alil late, this is my entry.php code
Expand|Select|Wrap|Line Numbers
  1.         echo "<table width='100%'>";
  2.     while($curr=mysql_fetch_array($result2))
  3.     {
  4.     $a=$curr['curr_name'];
  5.     $b=$curr['curr_amount'];
  6.  
  7.  
  8.     echo "<tr><td class='style4' width='100'>";        
  9.  
  10.  
  11.     echo "<input name='name[]' class='style4' size='15' value='" . $a . "'>";
  12.     echo "<td class='style4' width='100'>";
  13.     echo "<input name='amount[]' class='style4' size='15' value='" . $b . "'>";
  14.  
  15.     }
  16.     echo "</table>";
  17.  
and here is my update.php code,
Expand|Select|Wrap|Line Numbers
  1. $name= $_POST['name'];
  2. $amount=$_POST['amount'];
  3.  
  4.  
  5. $ids = (is_array($name)) ? implode(',', $name) : $name;
  6. mysql_query ("UPDATE currency SET curr_name IN($ids)");
  7.  
  8. $ids2 = (is_array($amount)) ? implode(',', $amount) : $amount;
  9. mysql_query ("UPDATE currency SET curr_amount IN($ids2)");
  10.  
  11.  
  12. echo $ids . "<br>";
  13. echo $ids2;
  14.  
i receives all the values from text boxes as i have printed them in last lines so that i can see if it gets the array. so i recieve all the values but i guess i am not writing the update line correct, while if i write delete insteate of update then it works but something is wrong with update.
Apr 1 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
1
by: chrisc | last post by:
Hello, Im using redemption in a database created in ms access. At the moment emails are generated depending on various actions within a database. To give an example: Public Const...
3
by: Tc | last post by:
Hi, I was curious, I am thinking of writing an application that loads a dataset from a database that resides on a server. The question I have is this, if multiple copies of the app will be...
2
by: BG | last post by:
We're having trouble writing the code to update a UI control (label.Text) from a secondary thread. We're using C# with Windows Forms. We have a main form named MainForm, a splash screen form...
8
by: TC | last post by:
Hello, I am making an asynchronous call to a webservice and trying to update the web page with the results. The page is not updating. Does anybody know why??? Below is my code:
3
by: Denise | last post by:
I am working with some pre-written code that dynamically builds a page with user controls based on data. I need to attach my Javascript to one of the controls on the form - I do not have access to...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
14
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.