UBB.Dev
Posted By: oceanwest Added Fields & Table need a little guidance. - 09/27/2004 11:58 PM
I have added a new field to my users table (U_UserGroup ) and also added a table (wt3_UserGroups) that has a list of values that I would like to display a popup in the editbasic.tmpl the popup will show the all values from the new table. Selecting the item from the popup will insert the primary unique key from the wt3_UserGroup table. into the field in the users table.

Then when I choose to display the data chosen the information from the table is display based upon the primary key...

what do i do next?
Then my next task is to build a front end for the new table to allow the addition of a new record.
I added the mod similar to the Modification Index here where when the poster
makes a new post they are presented with an alternate template.

Then on submit all the "text" from the fields are placed in the body. But I need the
data from the fields to also populate my new table.

I am trying to figure out how to insert data to a new table?
this is what I put in addpost.php
Code
 <br />if ($Board == "fmsd"){ <br />$query = " <br />	INSERT INTO {$config['tbprefix']}UserGroups (UG_Name,UG_Acronym,UG_State,UG_City,UG_URL,UG_Type,UG_Description,UG_Day,UG_Time,UG_Frequency,UG_Location,UG_PosterID) <br />	VALUES ('$Subject','$acronym','$state','$city','$meeturl','$meettype','$meetdesc','$meetday','$meettime','$meetfreq','$meetloc','$posterid') <br />"; <br />$dbh -> do_query($query,__LINE__,__FILE__); <br /> <br />} <br />


I think it is working with this... [fingers crossed]
need to limit the adding of record to only new posts

Code
 <br />if (($Board == "fmsd") && ($meetsubmit == "yes")) { <br />$query = " <br />	INSERT INTO {$config['tbprefix']}UserGroups (UG_Name,...


i put this in but doesn't add any then?
whats phpinfo() say $meetsubmit is when you click submit on the page? may be a problem of global off which in case you may have to add a $_GET or $_POST call on the value. All I can say is that when I am working on a script I use phpinfo(); alot to se what values the submit is actually submitting when it is clicked.
how do you use phpinfo()?

The variable $meetsubmit is supplied by a hidden tag in the template.

and I have it set at the very top of the script.

$meetsubmit = get_input("meetsubmit","post");
in the top of your php code under the <? put phpinfo(); it will provide all the details ya ever need including all variables and the like and their variables.
Thanks scrounger, I did check it and yes the variable is set.
just don't know why it fails the test just prior to at insert?
I really hadn't changed much other then add a few things, now when I edit the record the reply makes its own post instead of being tied to the parent post. Also other strange things when I hit the view thread sometimes i am taken to some arbitrary thread somewhere in the form.?

Perhaps it has something to do w/ preview template and some variable not passing?
Update.. Ok I managed to sort it out i had my update table smack in the middle of another if statement and that was why it went sideways, when I replied to the post.

So now I have the adding of data working fine. The fields in the template the posting of the data to the table I even am capturing the post number and placing it into a field in my new table. Now comes the task of pulling the data from table incase they edit the post.
Awesome! I can't believe I did it I have it working, my special forum is now posting and pulling and displaying correct data from the new table.

Now on to the next task of building a drop down list based upon data in the table.
I amuse myself. I just figured that part out too. Members can now choose which user group they belong to from a popup menu. That is dynamic based upon the new table. Also in the show flat under the avatar it also shows their selected group with a link to the thread? I am so stoked.
Cool keep up the good work
Thanks spoke too soon

I am getting a strange issue with showflat... replies don't show up but they do in showthreaded?

http://www.fmforums.com/threads/showflat.php?Cat=0&Number=126512&an=&page=0&vc=1

where do I begin to address this? HELP!
// User Group Display

$query = "
SELECT UG_Acronym,UG_PostID
FROM {$config['tbprefix']}UserGroups
WHERE UG_ID = '$ugID'
";
$sth = $dbh -> do_query($query,__LINE__,__FILE__);
list($ugAcronym,$ugPostID) = $dbh -> fetch_array($sth);


has something to do with this?
umm just one observation if that is inside one of the query calls you will have to rename the $sth to $sti,$stj, etc so if its inside a query call in showflat rename it and try that
ohh i think i get it st means string and the h / i / j is just another variable to hold the array?

It seems to work
I always name my querries differently even if they aren't being called inside another. A lot easier to keep track of 'em all imo :-)
yeah me to I often call things what they are so if I am querying for say finding pencils I call it $pencilsquery
ok my little statement in showflat is in the postrow area of the script just above

// New posts in topic?

the problem is that all the others users post is showing my data in their post?

how come? Did I put this in the wrong place?
i need to make my statement more restrictive.

Code
 <br />  // User Group Display <br /> <br />	if($ugID){ <br /> <br />	$query = " <br />		SELECT UG_Acronym,UG_PostID <br />		FROM   {$config['tbprefix']}UserGroups <br />		WHERE  UG_ID = '$ugID' <br />	"; <br />	$sti = $dbh -> do_query($query,__LINE__,__FILE__); <br />	list($ugAcronym,$ugPostID) = $dbh -> fetch_array($sti); <br />	} <br /> <br />	if(($ugPostID) && ($ugID)){ <br />    $postrow[$i]['usergroup'] = "Member: <a href='http://www.fmforums.com/threads/showflat.php?Cat=0&Number={$ugPostID}'/>$ugAcronym</a><br /><br />"; <br />	} <br />


that seemed to do it...

anyone else want to make this more tight?
© UBB.Developers