Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    An Update form update more then one Table at at time

    I have about 10 tables, that CANT be combined

    Reason is, the tables will include login information for about 500 employees, and I dont want to push that much info into one table incase I need to view from phpmyAdmin because of a site issue

    So, I have a profile page, where you will be able to update your login info.

    Im wanting to setup a way that when there viewing the update profile page, that it will update more then one table

    Im using a comman tag, id_agent, that helps everything link. So I need it to go into each table, and other tags like FirstName LastName and so on

  • #2
    New Coder
    Join Date
    Feb 2007
    Location
    NM. USA
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I am not sure I am understanding exactly what you are looking for. If you need to update more than one table you can just through multiple queries.

    If you need to update table X based on what is in table Y you can do something like

    UPDATE pizzaDeliveries set yummy=1 WHERE customerID IN (SELECT customerID FROM customers WHERE age > 15)

    PS: 500 records is nothing, what is the issue with the hoster? I have a very large MySQL table with keyword data (fully indexed) with almost a million records. but I don't often use phpMyAdmin.


    Good luck...


    _________________________
    "Insanity is hereditary - you get it from your children." Sam Levenson
    Web Development Company – Projects (Find $1 Photos for your website- search multiple stock agencies)

  • #3
    Regular Coder
    Join Date
    Dec 2005
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well the 500 Employees will go into At least 10 tables. 4 of which will but data holders for Personal notes, KBs, Annoucements, Scheduling, Ticketing. Also I will be linking into our Jive DB and then into our Outlook. So I am catching up on the records stored.

    None the less Im running into a problem.

    Im wanting to make it where I dont have to enter anything other then the Users Portal UserName and PassWord. I want it set to allow them to update the Login Tabes, problem is im using the id_agent field to base the update.
    Well, thats bad, because Ill order have to make there id_blank * 6 different loging tables. when I make there first ID_portal account.
    Other wise they cant update there email table correctly, because I cant update the id_agent, nor is it there for them.

    Exsample

    User_profile.php

    PHP Code:
    <?php
    $id_profile
    =$_GET['id_profile'];
    mysql_connect(localhost,$user_db,$pass_db);
    @
    mysql_select_db($database) or die( "Unable to select database");
    $query=" SELECT * FROM profile WHERE id_profile='$id_profile'";
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    mysql_close();
    $i=0;
    while (
    $i $num) {
    $id_agent=mysql_result($result,$i,"id_agent");
    $first_name=mysql_result($result,$i,"first_name");
    $last_name=mysql_result($result,$i,"last_name");
    $email=mysql_result($result,$i,"email");
    ++
    $i;
    }
    ?>
    <?php
    mysql_connect
    (localhost,$user_db,$pass_db);
    @
    mysql_select_db($database) or die( "Unable to select database");
    $query=" SELECT * FROM email WHERE id_agent='$id_agent'";
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    mysql_close();
    $i=0;
    while (
    $i $num) {
    $id_agent=mysql_result($result,$i,"id_agent");
    $id_email=mysql_result($result,$i,"id_email");
    $user_email=mysql_result($result,$i,"user_email");
    $pass_email=mysql_result($result,$i,"pass_email");

    ++
    $i;
    }
    ?>
     

    <form action="updated_profile.php?id_profile=<? echo $id_profile?>" method="post">
    <input type="hidden" name="ud_id_portal" value="<? echo $id_portal?>">
    <input type="hidden" name="ud_id_agent" value="<? echo $id_agent?>">
    <input type="hidden" name="ud_id_profile" value="<? echo $id_profile?>">
    <input type="hidden" name="ud_id_email" value="<? echo $id_email?>">
    <table>
    <tr><td>Agent ID: </td><td><b><? echo $id_agent?></B><br></td></tr>
    <tr><td>First Name: </td><td><input type="text" name="ud_first_name" value="<? echo $first_name?>"><br></td></tr>
    <tr><td>Last Name: </td><td><input type="text" name="ud_last_name" value="<? echo $last_name?>"><br></td></tr>
    <tr><td>E-mail: </td><td><input type="text" name="ud_email" value="<? echo $email?>"><br></td></tr>
    <tr><td>Email User: </td><td><input type="text" name="ud_user_email" value="<? echo $user_email?>"><br></td></tr>
    <tr><td>Email Pass: </td><td><input type="password" name="ud_pass_email" value="<? echo $pass_email?>"><br></td></tr>
    <tr><td><input type="Submit" value="Update"></td></tr>
    </form>
    updated_profile.php

    PHP Code:
    <?php
    $id_profile
    =$_GET['id_profile'];
    $ud_id_profile=$_POST['ud_id_profile'];
    $ud_first_name=$_POST['ud_first_name'];
    $ud_last_name=$_POST['ud_last_name'];
    $ud_email=$_POST['ud_email'];

    mysql_connect(localhost,$user_db,$pass_db);
    @
    mysql_select_db($database) or die( "Unable to select database");
    $query="UPDATE profile SET first_name='$ud_first_name', last_name='$ud_last_name', email='$ud_email' WHERE id_profile='$ud_id_profile'";
    mysql_query($query);
    echo 
    "Record Updated and return to your <a href=\"user_profile.php?id_profile=$id_profile\">Profile</a>";
    mysql_close();
    ?>
    <?php
    $ud_id_agent
    =$_POST['ud_id_agent'];
    $ud_user_email=$_POST['ud_user_email'];
    $ud_pass_email=$_POST['ud_pass_email'];

    mysql_connect(localhost,$user_db,$pass_db);
    @
    mysql_select_db($database) or die( "Unable to select database");
    $query="UPDATE email SET user_email='$ud_user_email', pass_email='$ud_pass_email' WHERE id_agent='$ud_id_agent'";
    mysql_query($query);
    mysql_close();
    ?>
    I cut out a few things for security reasons.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •