PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
ThePiston
Worker
Worker


Joined: Dec 22, 2004
Posts: 135

PostPosted: Sun Oct 09, 2005 8:37 pm Reply with quote Back to top

I have this code setup inside "edithome".
Code:
   {
   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
Code:
function saveoffice($user_id, $username, $storynum, $ublockon, $ublock, $broadcast, $oid, $practname, $add1, $add2, $city, $state, $zip, $phone, $fax, $website) {
    global $user, $cookie, $userinfo, $user_prefix, $db, $module_name;
    cookiedecode($user);
    $check = $cookie[1];
    $check2 = $cookie[2];
    $sql = "SELECT user_id, user_password FROM ".$user_prefix."_users WHERE username='$check'";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $vuid = intval($row['user_id']);
    $ccpass = $row['user_password'];
    if (($user_id == $vuid) AND ($check2 == $ccpass)) {
   if(isset($ublockon)) $ublockon=1; else $ublockon=0;
   $ublock = FixQuotes($ublock);
   $db->sql_query("UPDATE offices and SET oid='$oid', locationid='$location_id', practname='$practname', add1='$add1', add2='$add2', city='$city', state='$state', zip='$zip', phone='$phone', fax='$fax', website='$website', WHERE user_id='$user_id'");
   getusrinfo($user);
   docookie($userinfo['user_id'],$userinfo['username'],$userinfo['user_password'],$userinfo['storynum'],$userinfo['umode'],$userinfo['uorder'],$userinfo['thold'],$userinfo['noscore'],$userinfo['ublockon'],$userinfo['theme'],$userinfo['commentmax']);
   Header("Location: modules.php?name=$module_name");
    }
}
doesn't seem to be working and I'm sure there are plenty of mistakes. Can someone point them out to me so I can fix them? TIA


Last edited by ThePiston on Sun Oct 09, 2005 9:40 pm; edited 3 times in total
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Sun Oct 09, 2005 9:26 pm Reply with quote Back to top

First, a lesson in normailzation Smile. 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 Wink

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.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
ThePiston
Worker
Worker


Joined: Dec 22, 2004
Posts: 135

PostPosted: Sun Oct 09, 2005 9:36 pm Reply with quote Back to top

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 user's profile Send private message
ThePiston
Worker
Worker


Joined: Dec 22, 2004
Posts: 135

PostPosted: Mon Oct 10, 2005 10:32 am Reply with quote Back to top

Raven, did you get to look at the new code above?
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum