We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,011 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Set up login/registration form, need help showing figures from db

Hello,

I followed the tutorial from this site here and have added the login/registration to my test site.
The problem is I now need to add two currencies to each user. On the database I have created two rows for 'invested' and 'return' and need these to be unique to each user. I played around with various bits last night and managed to show the top row for ALL users, but not each user their own figures. I tried to do it myself by trial and error but I'm stuck.

From what I can see this login/registration is quite popular, so I'm hoping somebody could shed some light on what exactly I need to be looking at.

Thanks for reading

3
Contributors
9
Replies
1 Week
Discussion Span
4 Months Ago
Last Updated
10
Views
eklem
Newbie Poster
6 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Show what's in your database, and how your query in PHP looks (code).

pritaeas
Posting Prodigy
Moderator
9,286 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,457
Skill Endorsements: 86

Yes, i agree with pritaeas. It is going to be far easier to get help if you include at least the structure of the db table and a sample of the code you're using.

I'd bet you'll have to do a foreach loop inside a while loop, but that's just a stab in the dark without seeing what you're actually dealing with.

rsleventhal
Newbie Poster
10 posts since Jun 2008
Reputation Points: 11
Solved Threads: 2
Skill Endorsements: 0

Hello,

Sorry for the late reply I've been swamped with work.
I have uploaded the PHP to pastebin since I've also asked this somewhere else.

http://pastebin.com/gpnFDV2D

In the table I have the following (sorry, I'm not entirely sure what I should show you)

id_user
name
email
phone_number
username
password
confirmcode
invested
return

I'm still learning the basics, most of this is blowing my mind.

eklem
Newbie Poster
6 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Hello,

Just wondering if anyone could help me with this, I've been trying to do it myself but I haven't found any tutorials/guides on how to easily add this.

eklem
Newbie Poster
6 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

In the table I have the following (sorry, I'm not entirely sure what I should show you)

Show some sample data (what's in the table), and clearly state what you want as output.

pritaeas
Posting Prodigy
Moderator
9,286 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,457
Skill Endorsements: 86

Hi Pritaeas,

At the moment I have two records in the table 'fgusers3', these are registered users with the following data;

userid, name, email, phone_number, username, password, confirmcode, invested, return
1, Bill Gates, email@email.com, 07777777777, test, md5 hash, y, 100.00, 10.00
2, Sam Daar, test@email.com, 00000000000, admin, md5 hash, y, 50.00, 20.00

I need this to show each individual user their "invested" and "return" amount. So for example Bill Gates would show "invested 100.00, return 10.00". Sam Daar would show "invested 50.00, return 20.00"

Thank you for your help

eklem
Newbie Poster
6 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Following my previous post, I am trying to figure out where and how to add this function in the php code (on pastebin above).

Any help would be greatly appreciated, I'd consider donating a coffee to someone too :)

eklem
Newbie Poster
6 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

You'll need to copy for example the CheckLoginInDB function. The query you'll need would be this I guess:

function getInvestment($username)
{
    // open database, etc.

    $qry = "SELECT * FROM fgusers3 WHERE username='$username'";

    // get the result and do something with it.        
}
pritaeas
Posting Prodigy
Moderator
9,286 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,457
Skill Endorsements: 86

I am still trying to figure this out correctly. I have linked below the page where this all appears. The PHP on this page is correctly pulling the 'invested' and 'return' through fine, although only the top row - I did this purely to play with, however, I now have no idea how to get your suggestion to display correctly on this page.

Web page this is being displayed on: http://pastebin.com/NRsVdEjJ

Below is what I have so far, taken from what I've read online. I'm sure it's wrong though. I took bits from the CheckLoginInDB function.

    function getInvestment($username)
    {
    $qry = "SELECT donated, profit FROM $this->tablename where username='$username'";
    $row = mysql_fetch_array($qry;)
    $invested = $row['invested'];
    $return = $row['return'];
    }

Thank you

eklem
Newbie Poster
6 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0833 seconds using 2.79MB