change fields name in table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kabucek
Forum Commoner
Posts: 50
Joined: Thu Sep 04, 2008 2:20 pm

change fields name in table

Post by kabucek »

hello,

I have issue with my php configuration file.
There are 2 forms with some fields.
1 is for "member data" and second for "club info"
here are the parts of the code:

1part)

Code: Select all

$fieldName="city"; $customLabel="City";                         if ($errorArray[$fieldName]) {$customLabel="$customLabel*<BR><SPAN class=errorLabel>".$errorArray[$fieldName]."<P></SPAN>"; }                       $formFormatArray['labelOverride']=$customLabel; $tagName=$fieldName."TAG";                      $$tagName=$classLink->getFormTag($fieldName, $$dataArrayName, $formFormatArray);                        if ($errorArray[$fieldName] AND $formFormatArray['cssTagClassError']) {$$tagName=str_replace($formFormatArray['cssTagClass'], $formFormatArray['cssTagClassError'], $$tagName); }                       $$targetString.=$$tagName;



2nd part)

Code: Select all

<tr valign='top' bgcolor='#FFFFFF'>                               <td  width='105' height='26' align='left' class='paragraphbold'><div align='right'>City<font face='Arial, Helvetica, sans-serif' size='1' color='red'><em>*</em></font>{$errorArray["city"]}</div></td>                              <td height='26'><input name='recordDataArray[city]' value='{$recordDataArray['city']}'  type='text' size='55'>                              </td>                           </tr>



Those codes are in our reg-test.php file
user told me that they want more fields to be displayed on their management web interface,
so I went to another file listmem.php and add
this code that allows to see the Club address:

Code: Select all

$title="";                                  $fieldString.="                                         <TD $fieldStyle>                                            <NOBR>{$itemRecArray['street']} {$itemRecArray['city']} {$itemArray['state']} {$itemArray['zip']} $errorFlag</NOBR>                                             </TD>                                       ";                                      $fieldTitleString.="                                            <TD $fieldTitleStyle>                                               Club Address                                                </TD>                                           ";                                      $fieldCount++;  



- but this is not working because there is previous form with the same field names in
reg-test.php file and its picking up all the time city from the previous form. - where the member lives and
not the club city.
Any help or suggestions?
thanks
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: change fields name in table

Post by Jade »

Did you give those different names from the other fields? If they all have the same names that might be causing the problem. (IE two state fields)
kabucek
Forum Commoner
Posts: 50
Joined: Thu Sep 04, 2008 2:20 pm

Re: change fields name in table

Post by kabucek »

previous coder put the same names for these 2 different forms and that's why its mess with
the registrations.
I'm looking for a way to rename fields from the second form (club..)
thanks
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: change fields name in table

Post by Jade »

np :)
kabucek
Forum Commoner
Posts: 50
Joined: Thu Sep 04, 2008 2:20 pm

Re: change fields name in table

Post by kabucek »

you mean not possible ??
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: change fields name in table

Post by Jade »

Of course it's possible. You need change the names of the array fields wherever the club information is being stored.

Code: Select all

 
$title="";
$fieldString.="<TD $fieldStyle><NOBR>{$itemRecArray['club_street']} {$itemRecArray['club_city']} {$itemArray['club_state']} {$itemArray['club_zip']} $errorFlag</NOBR></TD>";                                      
$fieldTitleString.=" <TD $fieldTitleStyle>Club Address                                              </TD>";
$fieldCount++;
 
Then wherever this information is being stored/or loaded for the first time you need to make sure it goes into the same array variables.
kabucek
Forum Commoner
Posts: 50
Joined: Thu Sep 04, 2008 2:20 pm

Re: change fields name in table

Post by kabucek »

ok this will work only to the new registrations,
but what about the old registrations?
i want to view the data from the old registrations.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: change fields name in table

Post by Jade »

Yes, it will work. All you have to do is make sure what's being pulled from the database/file (whatever you're using to store this data) loads the appropriate information into those fields. It doesn't matter if the data is being stored with another name as long as you load it in correctly and then save it back correctly.
Post Reply