{
print "<table width=100% border=1>";
echo "<tr><b><h4>Use the form below to add additional offices.</b></h4>"
."<form name=\"Office\" action=\"modules.php?name=$module_name\" method=\"post\">"
."<br><td><font color=AE4355><b>Step 1, please check where this office is located.</b></font><br><br>"
."<input type=\"radio\" name=\"locationid\" value=\"1\" $sel1> "._FW."<br>"
."<input type=\"radio\" name=\"locationid\" value=\"2\" $sel1> "._NW." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"3\" $sel1> "._N." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"4\" $sel1> "._S." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"5\" $sel1> "._E." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"6\" $sel1> "._CH." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"7\" $sel1> "._ML." <br>"
."<input type=\"radio\" name=\"locationid\" value=\"8\" $sel1> "._RF." <br><br></td>";
echo "<td><font color=AE4355><b>Step 2, please change info below to alter or add an additional office location where you can be found by the public.</b></font><br><br>"
."<b>"._PRONAME."</b>: <b>".$userinfo['name']."</b><br>"
."<b>"._PRACTNAME.":</b><input type=\"text\" name=\"practname\" value=\"\" size=\"50\" maxlength=\"100\"><br>"
."<b>"._ADDRESS1.":</b><input type=\"text\" name=\"add1\" value=\"\" size=\"30\" maxlength=\"100\"><br>"
."<b>"._ADDRESS2.":</b><input type=\"text\" name=\"add2\" value=\"\" size=\"30\" maxlength=\"100\"><br>"
."<b>"._CITY.":</b><input type=\"text\" name=\"city\" value=\"\" size=\"30\" maxlength=\"50\"><br>"
."<b>"._STATE.":</b><input type=\"text\" name=\"state\" value=\"VA\" size=\"2\" maxlength=\"2\"><br>"
."<b>"._ZIP.":</b><input type=\"text\" name=\"zip\" value=\"\" size=\"13\" maxlength=\"13\"><br>"
."<b>"._PHONE.":</b><input type=\"text\" name=\"phone\" value=\"(804) \" size=\"14\" maxlength=\"14\"><br>"
."<b>"._FAX.":</b><input type=\"text\" name=\"fax\" value=\"(804) \" size=\"14\" maxlength=\"14\"><br>"
."<b>"._WEBSITE.":</b><input type=\"text\" name=\"website\" value=\"http://www.\" size=\"50\" maxlength=\"100\"><br>";
echo "<td><font color=AE4355><b>Step 3, click 'Add Office' to save this office into the ROS database.</b></font><br><br>"
."<input type=\"hidden\" name=\"oid\" value=\"".intval($userinfo['oid'])."\">"
."<input type=\"hidden\" name=\"op\" value=\"saveoffice\">"
."<input class=button type=\"submit\" value=\""._SAVECHANGES."\">"
."</form></td></tr>"
;
}
in the code above people can shoose an area, then input the address of the office and then it will save the data (and update "oid" to next number in DB (int11 is 'type')
I'm trying to use this form to update the info in it into multiple tables
Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
Posted:
Sun Oct 09, 2005 9:26 pm
First, a lesson in normailzation . If you are carrying the same fields on both tables that is a design no-no and wastes space. There is a process called normalizing which structures repetative data into 1 table with a common key. Now, on to your answer
Assuming that you do have those fields in both tables, here is what you would use.
Code:
$sql = "UPDATE ".$user_prefix."_users u, ".$user_prefix."_offices o SET u.storynum='$storynum', u.ublockon='$ublockon', u.ublock='$ublock', u.broadcast='$broadcast', o.storynum='$storynum', o.ublockon='$ublockon', o.ublock='$ublock', o.broadcast='$broadcast' WHERE u.user_id='$user_id' AND u.user_id=o.user_id";
$db->sql_query($sql);
or
Code:
$sql = "UPDATE ".$user_prefix."_users u, ".$user_prefix."_offices o SET u.storynum='$storynum', u.ublockon='$ublockon', u.ublock='$ublock', u.broadcast='$broadcast', o.storynum=u.storynum, o.ublockon=u.ublockon, o.ublock=u.ublock, o.broadcast=u.broadcast WHERE u.user_id='$user_id' AND u.user_id=o.user_id";
$db->sql_query($sql);
If it were me I would NOT do this, only because it is dangerous if you don't know what you're doing, but it is also much simpler to just do
Code:
$db->sql_query("UPDATE ".$user_prefix."_users and SET storynum='$storynum', ublockon='$ublockon', ublock='$ublock', broadcast='$broadcast' WHERE user_id='$user_id'");
$db->sql_query("UPDATE ".$user_prefix."_offices and SET storynum='$storynum', ublockon='$ublockon', ublock='$ublock', broadcast='$broadcast' WHERE user_id='$user_id'");
The latter also allows you the ease of checking return code statuses for each update attempt in the event something goes wrong.
eh, sorry, I was updating my post while you were replying to mine - I also just realized that I didn't need to update both tables anyway, just the offices one
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum