472,371 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how to update record with 2 tables?

i have 2 tables,
1. account

2. accounttype

i can add record by join the table,
but if i need update record, it cant,
can some 1 help me?
how to update?

Expand|Select|Wrap|Line Numbers
  1. <html><head></head>
  2. <body>
  3. <?php
  4. $jenis =$_POST['accounttypeid'];
  6. $connect =mysql_connect("localhost","root","") or die (mysql_error());
  7. $select = mysql_select_db("phplogin") or die (mysql_error());
  8.    $q = mysql_query("select * from accounttype");
  9.         while ($row = mysql_fetch_assoc($q)) 
  10.         {
  11.                 $jenis .= "<option value = $row[accounttypeid]>$row[type]";
  12.         }
  13.         ?>
  14.         <?
  16. if (isset ($_POST['submit'])) {
  18.    $name = $_POST['name'];
  19.    $sid = $_POST['accounttypeid'];
  20.    $ID=$_GET['ID'];
  23.       $updatelink="Update account set name='$name', accounttypeid ='$sid'";
  24.       mysql_query($updatelink) or die(mysql_error());
  25.       print "Link updated.";
  27. } else
  28. {
  30.    $ID=$_GET['ID']; //gets the id from URL
  31.    $sql="SELECT account.id, account.name, accounttype.type from account, accounttype where account.accounttypeid = accounttype.accounttypeid and account.id='$ID'";
  32.    $result=mysql_query($sql) or die("Could not get button"); 
  33.    $row=mysql_fetch_array($result);
  36.    ?>
  37.    <form method="post" action="lista.php" >
  38.    <table><tr><td><input type="hidden" name="ID" value="$ID"></td></tr><tr><td>Name: </td> <td><input name="name" type="text" id="name" value="<? echo $row['name']; ?>"></td></tr>
  39.    <tr><td>
  40.      Accounttype: </td> <td><select name="accounttypeid"><?php print ($jenis); ?>
  41. </select></td></tr>
  42.    <tr><td colspan="2"> <input type='submit' name="submit"  value='submit'></td></tr>
  43.    </table></form>
  46. <? }
  47. ?>
  48. <form method="post" action="viewa.php">
  49. <table><tr><td>
  50. <input type="submit" name="view" value="View">
  51. </td></tr></table></form>
  53. <form method="post" action="a6.php">
  54. <table>
  55. <tr><td>
  56. <input type="submit" name="back" value="Back">
  57. </td></tr></table></form>
  58. </body></html>
Sep 14 '09 #1
1 1947
I gather you are asking for assistance creating an UPDATE query across multiple tables?

Expand|Select|Wrap|Line Numbers
  1. UPDATE tableName t1 JOIN tableName t2 ON t1.field = t2.field SET t1.field = 'value', t2.field = 'value', etc. WHERE t1.field = 'value' AND t2.field = 'value';
Sep 15 '09 #2

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

Similar topics

by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN'...
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city ...
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
by: jpr | last post by:
Hello, I know that this is not the rule but need some help. My datbase has three tables: MASTER TEMPLATES FORMS I have a form which is based on a table named MASTER. I have a primary key...
by: Roy | last post by:
Hi Access gurus, I have a A2K application.The data in the database is updated daily by a excel download.I have a master n related tables keyed in by a OrderID.I have a problem in updating data.If...
by: Scotty | last post by:
I like to have a good insert, update and delete code The code below sometimes workl ok sometimes doesnt work, what i am doing wrong?? Sub SaveAny() Dim command_builder As New...
by: BobLewiston | last post by:
Some of you may have seen my earlier thread “PasswordHash NULL problem”. I’ve started a new thread because investigation has shown that the problem is actually quite different than I previously...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.