Jump to content

Is this possible?


DaVuLf

Recommended Posts

First off, I must say that this is my first post, so I don't expect much. That said, I hope to be pleasantly surprised.

Now, what I am looking to do is create a set of php files linked to a mySql database in order to track a portfolio.

Let me quickly explain. Suppose we have a first page with a form on it. It asks you to input your name, select a stock, the amount wanted, and has a 'purchase' button. The back-end calculates the cost, adds the shares to your portfolio (all stored in the database) and shoots you out your balance.

Now, that is the base of this. Because this will all be 'imaginary' I will want to hard-code all of the imaginary stocks, and their related values. These values will be attached to a time stamp, which leads to the next issue. I want to be able to have this on a network, where the master computer clicks the 'begin' button, and every minute, the values of the stocks change based on variable name (ie. Minute 1: SHARE1 = $1... Minute 2: SHARE2 = $1.05 etc.)

I'm relatively sure that those things are possible, but I'm not sure how I would first approach this issue. In the end, I want to have multiple transactions, a way to undo past transactions, a way to access every account from any computer on the network, and a way to determine the 'High Scores' as this progresses.

Any and all help will be appreciated. I thank you for your time.

-DaVuLf
Link to comment
Share on other sites

[!--quoteo(post=373851:date=May 14 2006, 07:56 PM:name=DaVuLf)--][div class=\'quotetop\']QUOTE(DaVuLf @ May 14 2006, 07:56 PM) [snapback]373851[/snapback][/div][div class=\'quotemain\'][!--quotec--]
First off, I must say that this is my first post, so I don't expect much. That said, I hope to be pleasantly surprised.

Now, what I am looking to do is create a set of php files linked to a mySql database in order to track a portfolio.

Let me quickly explain. Suppose we have a first page with a form on it. It asks you to input your name, select a stock, the amount wanted, and has a 'purchase' button. The back-end calculates the cost, adds the shares to your portfolio (all stored in the database) and shoots you out your balance.

Now, that is the base of this. Because this will all be 'imaginary' I will want to hard-code all of the imaginary stocks, and their related values. These values will be attached to a time stamp, which leads to the next issue. I want to be able to have this on a network, where the master computer clicks the 'begin' button, and every minute, the values of the stocks change based on variable name (ie. Minute 1: SHARE1 = $1... Minute 2: SHARE2 = $1.05 etc.)

I'm relatively sure that those things are possible, but I'm not sure how I would first approach this issue. In the end, I want to have multiple transactions, a way to undo past transactions, a way to access every account from any computer on the network, and a way to determine the 'High Scores' as this progresses.

Any and all help will be appreciated. I thank you for your time.

-DaVuLf
[/quote]

Yes, all that seems possible, but you won't get much help on the forum, as most of your issue seems to be database design and such, not really what this forum is for.
Link to comment
Share on other sites

Yes. Everything you have talked about is possible. PHP is a very powerful tool. You are not going to get responses on how to write it. If you want somebody to write it for you, post in the [a href=\"http://www.phpfreaks.com/forums/index.php?showforum=8\" target=\"_blank\"]Freelancing Section[/a].

We are here to help you with specific problems. You'll have to take the project on and if you get stuck, come here and ask a question about your specific problem. And even though this is a php forum, we can usually answer questions that deal with mysql also.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]
Link to comment
Share on other sites

Do you have any programming experience AT ALL? If not, this is way too complicated and extensive for your first project. It can be done, and for someone with the experience it's not that hard either (just alot alot of work) but I'm not sure you can, yet.

I can recommend "MySQL/PHP Database Applications" by Jay Greenspan and Brad Bulger. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
Link to comment
Share on other sites

I would like to thank you all for the quick responses, and I look forward to working with you in the future.

There is no budget for this project, so I would not feel comfortable posting it in the freelance section. Additionally, I have until next March (07) to finish this, so I have quite a lot of time to work on it. If anyone could point me in the direction of some links to tutorials or other things similar to what I am looking for, that would be great.

I have programmed a few forums and portals and such using PHP, and I'm pretty good at MSAccess. I figure with those two components, I can eventually pull this project off. I am just at a loss as to where I would even begin.

If anyone has a suggestion or two, I would greatly appreciate it.

448191: Thank you for the book recommendation, however I'm not looking to spend any money on this project as it isn't for any type of profitable venture. Mostly, I just want to see if I can do this. I have programmed something similar using MSExcel and Macromedia Flash, but the integration is not there. Because of this, I think making it in PHP and MySql would be preferable.
Link to comment
Share on other sites

Okay, so I've begun on my quest to get this thing to work.

I've set up a database, with several fields in it. I've completed an HTML form that allows me to input data (direct to variables).

Now, I was wondering how to do something a little more complicated; add a portfolio. Currently, I can have several different fields, such as the team name, starting balance etc. which I input straight from the beginning. I need to find a way whereby I can add different stocks to this persons portfolio. I was thinking about adding different entries, but would that be the best way?

For instance:

[code]
Team           Amount           Stock           Value     Transaction Worth
Team 1                10           GOOG          $41           $410
Team 1                10           YHOO          $73            $730
[/code]

This way I could track the number of shares, of which type, and their value at the time of purchase. However, I would also need to have somewhere to track the master balance. I figure that I could sum the transaction worth field, and subtract it from a master balance. What I'm worried about, is that this balance could end up below zero. What I must do, then, is determine the total transaction worth, check it against the balance, if it is lower, then it will go, otherwise, return an error.

The thing I'm really struggling with here is the need to have a main balance. I suppose I could create a seperate table for each person, but I'm not sure if that is necessary, and it seems rather cumbersome.

Any help would be appreciated.

Thanks,
DaVuLf
Link to comment
Share on other sites

[!--quoteo(post=374045:date=May 15 2006, 12:11 PM:name=mb81)--][div class=\'quotetop\']QUOTE(mb81 @ May 15 2006, 12:11 PM) [snapback]374045[/snapback][/div][div class=\'quotemain\'][!--quotec--]
DaVulf,

Again, your question is concerning database design and algorithms and such, and we are really not here to do that for you, this forum is for coding problems.
[/quote]

mb81: I appreciate that you keep pointing that out, but the other members who replied stated that they were apt to help with this sort of issue as well. Although I'm sure that question may relate to database design, I'm sure php coding will be needed to make it effective. As such, I'm sure that many of the coders on this forum would be able to lend aid.

If you could suggest somewhere that I may receive a quicker and more complete reply, then please do so and I will be thankful.
Link to comment
Share on other sites

As mb81 mentioned, this has alot to do with database design. Though I am not opposed to helping, there isn't enough information to help.

It has been my experience that php and databases are essential to one another.
Since you are in the begining phase of your project I would recomend taking the time to plan the database. It is more important than the php code needed to access it, at least for now.

There are many articles on the net dealing with project planning. For the most part they all say about the same thing: Consider everything.

[a href=\"http://www.phpfreaks.com/tutorials/135/0.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/135/0.php[/a]
Link to comment
Share on other sites

Ferenc: Thanks for the reply and for the link. I'll definately go through that in order to sort this thing out.

I was wondering, if you could answer that one question though, because I'm not familiar enough with databases to do so. Now, as I explained a few posts ago, I'm looking to have a portfolio system run through a database. I'm not sure if I should have a table for each person, or if I should have columns for each person. I'm thinking that the table system would be better, but I'm really not that experienced with these things.

Thanks again for the link and reply. :)
Link to comment
Share on other sites

Alright. I've made some progress on this, and now I have a couple more specific questions.

1. If I have two fields in a table, how do I calculate them? (ie. Field 6 * Field 8 = Value to be placed in Field 9)
2. How do I tell it to check though another table to search for a value. (ie, look in 'VALUES' for $team where $time = 1... Then, take that number, and multiply it by Field 5, storing the result in Field 10.)
3. How do I check a value against a field? Suppose I want to check the total value of #2 against Field 9 from the last row of the table?
4. How do I Sum fields through a query?
5. How do I do error reporting? Currently, even if something doesn't work, I don't know that unless I go through phpMyAdmin to make sure. This happens mostly in table creation.

Thanks,
DaVuLf
Link to comment
Share on other sites

one piece of advice i can give you is to look into relational databases/tables. the basic principle behind them is you have several tables that are linked to each other by common columns. for example:

[code]
                       Portfolio
                       =========
+------------------->  User_Id
|                      Stock_Id <--------------------+
|                                                    |
|                                                    |  
|                                                    |
|  Account Info     Transactions         Stock Info  |
|  ================================================= |
+->User_Id <------> User_Id         +--> Stock_Id  <-+
   User_Name        Stock_Id  <-----+    Stock_Name
   User_Pass        Trans_Id             Current_Price
   User_Regdate     Trans_Quantity       Stock_Blah
   User_Blah        Trans_Sell_Price     Stock_Blah
   User_Blah        Trans_Date           Stock_Blah
   User_Blah        Trans_type           Stock_Blah
[/code]

this way you significantly reduce the amount of data being stored in your database. Also, instead of having to update the same current stock prices for each and every person who has that stock in their portfolio, all you have to do is update the price(s) in the stock_info table. The account info table holds the user's basic account information. I included some basic column examples (and the blah's are there for the hell of it). The transactions table would hold each transaction made. Specific columns would include the date/time of transaction, the type of transaction (buy or sell), the quantity of stocks bought/sold, a unique transaction id, and again, instead of repeating the user's information over and over for each transaction, you would have the User_Id column in this table as well, and you would just refer to the user's information by their Id. Same thing with Stock_Id.

The portfolio table will hold all the stocks that are in everybody's portfolio. It can be as simple as how I listed it above, with the user's id and the stock id. This way, you can simply do a search for all stocks associated with the user id, linking the user info you want to display by the user id, and showing stock info linked by stock id. you can also do other searches, like, show all users who have stock x in their portfolio. lots of possibilities.
Link to comment
Share on other sites


Alright. I've made some progress on this, and now I have a couple more specific questions.

1.
[code]$sql = "SELECT (Field 6 * Field 8) AS value FROM mytable WHERE some_id = '$id'";[/code]
But you will need establish a unique identifier, or at least you should.

The code to get data from the database is trivial (for some people). All the information for these types of things are at mysql.com and php.net

The post below is a great suggestion. A relational database is perfect for your project!

Ask your self what you want to track, and how can you do that with as little information in the database as possible?

Say a user logs in and his id = 4, and is a member if team 5 ( or maybe he belongs to teams 3 and 7 aswell). How is your project going to know where to look? How are we to know what table the team stock infos are held in? Or is it in a individual portfolio? If so th......
This could go on and on...

All these things need to be planned for before you start writing php code.
Once the data is stored access and math functions are simple enough if we know where to look!

on to something useful...

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]5. How do I do error reporting?[/quote]
after each query make the script tell you if it failed using die()
[code]$sql = mysql_query("SELECT * FROM my_table") or die(mysql_error());[/code]

Link to comment
Share on other sites

Thanks for the help everyone. Ferenc, the error reporting I will most definately use.

Crayon: Really nice information there. Very thorough.

The information that you guys provide is based on something far more complex that I'm trying to make.

Let me try to clarify what I'm doing, as this isn't as complex as you all seem to think.

I'm the VP Operations for a day trading club on my campus. Every year we run a stock trading simulation, using made up stocks, made up prices, and made up teams. This simulation runs for 60 minutes, with 20 stocks. That means that I need 20 tables, with 60 rows, and need these to be accessed based on which minute we are currently at.

There are approximately 10 people who enter transaction information during the competition. They need to be able to select a team, and add the transaction information. Then the back-end will calculate if the transaction is within the team's balance. If it is, then the transaction gets recorded, otherwise it posts the highest possible transaction in its stead.

The reason I'm using PHP and mySql is so that we can access any team from any of the 10 people who enter transaction information. Additionally, I think it will be easier to determine a winner.

Eventually, I would like to be able to produce a high score table.

Now, the reason I'm having 1 table for each team, is because I will enter the team names manually, and there is a limited amount (so I don't have to worry about username/password/ip or anything like that). The only thing I wonder about the high score table, is how I would constantly sum every table, in order to come to a total balance to compare.

I'm positive that all i'm trying to do is possible, and I've already figured out aroudn a quarter of what I'm trying to do, but there are still some things I'm trying ot figure out.

Thanks again to everyone who has replied :).

Edit: The information that I need for each team is the following:
TeamName, TeamBalance, TransactionList, PortfolioValue, PortfolioContents

TeamName: The name of the team
TeamBalance: The total balance remaining to the team.
TransactionList: The list of all transactions that this team has done since the beginning of the competition.
PortfolioValue: This includes the monetary value of each of the stocks contained in their portfolio.
PortfolioContents: This includes which stocks the team owns, and what price they originally bought each stock for.
Link to comment
Share on other sites

Thanks for the relocation Andy.

I'm pretty sure I have the database design down as far as I know how to. I don't think I really need any relationships, as I can't see how they would make this any simpler.

Again, I'm a beginner at this sort of thing, so you would all be far more knowledgeable than I would, and know more of what I should use than me.
Link to comment
Share on other sites

While you're waiting for one of our real db experts to give their input, consider that sooner or later you'll want some 'nice' administration tools for editing your db tables conveniently. phpMyEdit from [a href=\"http://platon.sk/projects/main_page.php?project_id=5\" target=\"_blank\"]http://platon.sk/projects/main_page.php?project_id=5[/a] is worth its weight in gold (and free) as it can save you hours of time.
Link to comment
Share on other sites

Wow... I missed this entire thread. Granted, there were no specific PHP questions (*yet*), I'm not sure I understand the negativity and attitude towards an important MySQL question on a DB forum, even if it wasn't in the most ideal forum. Thumbs up to CrayonViolet for stepping in.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.