Adding a column to DB

Started by Fog, November 16, 2013, 10:19:52 PM

Previous topic - Next topic

Fog

What I'm trying to do is have a way to input peoples records in a NFL Pickems Game we have going and have it display on their profile.

I created a new column on my DB but is doesn't want to display the value that I want it too.

I copied the same code that you see for displaying the battle stats you would see when viewing a profile.

At that point I can see where it displays that stat(s) twice when you view a persons profile.

The code feeds off the "atk" and "def" columns on the members table.

So I created a column called "posts1" on the same members table and changed up the profile-view.php code to include that new column and nothing was displayed. Then I changed it to just "posts" and I could see how many post I had.  The code seems to work fine it's the column on the DB that has me wondering if I have it setup right to manually going and add their respective record for this game and just have it displayed on their profile and where they post.

I'm a bit lost on this idea

Thanks
Fog

Chen Zhen


Fog,

There are 2 necessary edits within Load.php where you need to have it put the data into the $user_info array.


Fog

I'm not worthy of your vast knowledge...thank you

SA

you can do it without editing the $user_info array in load.php
just global
$user_settings

and then use $user_settings['output'] where output would be the value from the db so if the new column in db is output use that
http://samods.github.io/SAChatBar/

Customizer @ SimpleMachines

SA

it been a while that info is not entirely correct but that way does work just not sure about inside topics or profile cant rember i did facebook,twitter,gplus mods using user_settings to save on edits
http://samods.github.io/SAChatBar/

Customizer @ SimpleMachines

Fog

Perfect SA...that helped me find part of the load.php file that housed the part that I could tweak to make the new column show up when viewing ones profile.

Now I need to figure out how to create a way to change the numbers through admin controls.

Thanks Guys.

SA

you could easly add settings to admin thru hooks or just modify the files

manageSettings.php

$config_vars = array(
// Big Options... polls, sticky, bbc....
array('select', 'pollMode', array($txt['disable_polls'], $txt['enable_polls'], $txt['polls_as_topics'])),


replace with


// my new admin item
array('int', 'my_newOption'),
'',
       // Big Options... polls, sticky, bbc....
      array('select', 'pollMode', array($txt['disable_polls'], $txt['enable_polls'], $txt['polls_as_topics'])),


that will add a new int box in admin under feature and options and this
$txt['my_newOption'] = 'my new option';
can go in you language file

then you can call that setting like so  $modSettings['my_newOption']
http://samods.github.io/SAChatBar/

Customizer @ SimpleMachines

Fog

Easy for you SA  :)

I'm a theme guy, this php stuff is all new to me.

I gather I need something like this from what you're telling:

//Pickems Win/Lose Record

array('int' , 'Pickems Settings', array($txt['members_wins'], array($modSettings['Number input to db column#XX']))'',

array('int' , 'Pickems Settings', array($txt['members_loses'], array($modSettings['Number input to db column#XX'])),


What would be ideal.

If there was a way for a member to go to their profile and forum profile and have a way to enable "Their NFL Pickems Record" then if the check the box to enable it shows drop down boxes that allow the member to input wins and loses in two different boxes.

What I'm looking at is how when you redirect a board with an URL.

once you click on the redirect box it creates a box to add your respective URL.  This will help me learn how that type of function works.

If it's easier to do on the admin side that would work as well.

Thanks for the help...

Fog

What I did that made it easier...

I created a new Profile Field and was able to allow the members to enter their own record.

SA

aha i always forget custom profile feilds are there  :P
usfull stuff eh?
http://samods.github.io/SAChatBar/

Customizer @ SimpleMachines

Fog

It's not exactly what I was looking for, but will suit most of our members fancy in a fashion that it displays their pickems record once they enter it manually.

I'm not sure if I'm pointed in the right direction or not, but I'm learning...lol

What I'd like to create is a way for a game keeper to enter results that in return creates a record displayed on members/users profile.


SA

well the game keeper could make a script that update them custom profile feilds witht the records
is the game keeper you ?
is it only admin that can enter them records?


$smcFunc['db_insert']('ignore', '{db_prefix}themes',
       array('id_member' => 'int', 'id_theme' => 'int', 'variable' => 'string', 'value' => 'string',),
      array(['id_member'], 1, 'varible', 0,), array('id_member', 'id_theme') );


thats a simple insert into the themes table werte custom profile filds are stored "varible" will be the varible in the themes table for your feild "id_member" is the member it applys to

i can try wip somthing quick up for you but it wont be 100% but it would be a start if it for only admin id be inclined to make a simple ssi page with the input boxes for what not

what needs to be inserted in there?
http://samods.github.io/SAChatBar/

Customizer @ SimpleMachines

Fog

In most cases it would be me or another admin that could control the input of # of wins and loses.

Thanks again SA...

I have this week off and will be able to mess around with a few things.

Fog

  Here's a bit of a back drop of what my site and users are about.  We're a Fantasy Sports Community where you can post your own Fantasy Leagues on the forum.  We also host our own made up games as well.

  NFL and NASCAR seem to rule our forum as far as sports goes but our users love Battle and they play the arcade games as well.  One, of our own games is a NFL Pickems Game and you have to pick the winning team of each game.  We do this for 17 weeks and then we combine each week to create an overall record for each user.  This is done manually by one of our members and is posted each week.  She does this for two sites and has to login over 100 peoples picks each week.  She does it all by pencil and paper.

  A cool idea to help her, is giving her or another user, the means to input a simple win lose record via the members forum and profile settings.  Start with a permission setting to allow a mod or a super mod to edit this. (edit one php.code?)  Then you would have an input box for both wins and loses when you viewed their profile. (edit 2nd php.code?)  Then you have to have it show up not only in their profile but in their display. (edit 2 more php.codes?).  Then you have to modify languages for new wording and I'm sure I probably missed a few other codes one would have to tweak as well.

  I stumble around looking for which php file to edit.  .This is where most of my time is spent looking through these files and understanding the difference if I have to edit a display file or a profile file. This lack of knowledge tends to hamper me in asking for help or doing searches with the right key words but I'm learning.  I've been a long time theme maker for the sports site I admin on.  I've learned a ton of css and know enough of php to blow up a website and fix it again. Overall......I suck at PHP

  I'm not looking to reinvent smf but understand how I can tweak it to suit my/our users needs.  This site along has been a great tool for me to learn and apply things towards my site.  In return I can't thank you enough SA or UD for the time you've both spent in creating what you guys do.  I've learned so much you guys...Thanks

Sorry about the novel...

Fog