Page 1 of 2

Trying to setup PHP Template Website

Posted: Fri Sep 04, 2015 5:17 pm
by Bmoney0313
Hey guys,

I'm trying to setup a PHP template based website for a league I'm in. I'm now trying to read the Players.xml file from STHS and parse out the players that belong to each team. I know there's a <TEAM> attribute I just can't figure out how to search for that attribute then return all the player statistics from the XML file.

I've found the simplexml_load_file element within PHP but I'm stuck on how to search for a team name then return the player stats.

Any help would be greatly appreciated.

Thanks.

Re: Trying to setup PHP Template Website

Posted: Sat Sep 05, 2015 12:25 pm
by SimonT
Hey.

The SQLite database would be better. Check this : https://github.com/SimonT-STHS/STHS-PHP-Code

It's a couple of sample of code I did that might help you.

Re: Trying to setup PHP Template Website

Posted: Sat Sep 05, 2015 12:49 pm
by Bmoney0313
Much appreciated. I'm waiting for the commish to export the SQLite DB so I can start testing. Any chance you might have a sample DB somewhere I could test with?

Re: Trying to setup PHP Template Website

Posted: Sat Sep 05, 2015 1:45 pm
by SimonT
I don't have any publish around right now. Sorry. Worse case, send me an email and I'll reply you with one.

Re: Trying to setup PHP Template Website

Posted: Sat Sep 05, 2015 2:01 pm
by Bmoney0313
What's the best email address to reach you at?

Re: Trying to setup PHP Template Website

Posted: Sat Sep 05, 2015 2:11 pm
by Bmoney0313
Actually can I output a DB from the v2 demo?

Re: Trying to setup PHP Template Website

Posted: Sat Sep 05, 2015 2:35 pm
by SimonT
I think you can! Good thinking!

Re: Trying to setup PHP Template Website

Posted: Sat Sep 05, 2015 3:53 pm
by Bmoney0313
Alright I was able to output a STHS.db. I ran the PlayerInfo.php file you setup and I get all the applicable fields for Incorrect Player. I guess I'm wondering how I would use that to pull out all the players for a specific team?

Re: Trying to setup PHP Template Website

Posted: Sat Sep 05, 2015 5:09 pm
by SimonT
Try with this syntaxes

PlayerInfo.php?Player=2

I had the information in GitHub also.

Re: Trying to setup PHP Template Website

Posted: Sat Sep 05, 2015 6:06 pm
by Bmoney0313
Alright that was the only thing I didn't try...I was trying Name= and ID= but not Player=. So back to the original question...How can I use this to pull players that are on a certain team and display that as a roster screen?

Re: Trying to setup PHP Template Website

Posted: Sun Sep 06, 2015 10:27 am
by SimonT
This code is far from being finished. It’s only a proof of concept. For your question, you have to make the SQL query and program it yourself in php. I cannot teach you that.

Re: Trying to setup PHP Template Website

Posted: Sun Sep 06, 2015 2:31 pm
by Bmoney0313
Understood. Thanks for the assistance so far.

Re: Trying to setup PHP Template Website

Posted: Sun Sep 06, 2015 4:29 pm
by Foo
And if it can boost you to continue, I was in the same seat 10 years ago, no knowledge at all of php and mysql database...

Re: Trying to setup PHP Template Website

Posted: Sun Sep 06, 2015 4:50 pm
by Bmoney0313
Thanks for the encouragement Foo...I'm stumbling along to figure it out. I work in IT but I'm on the server virtualization side so this programming side is a bit foreign to me.

Re: Trying to setup PHP Template Website

Posted: Tue Sep 08, 2015 8:28 am
by Bmoney0313
Alright I've been successful in pulling roster info based on Team # in PlayerInfo, but as you can imagine that is causing the roster page to display all players that meet the team number (pro and farm). I'm trying to separate the pro from the farm based on the team name in the PlayerInfo table but I'm having no luck due to the space in the team names. Anyone have any ideas?

My code looks like this:
$MainQuery = "SELECT Name FROM TeamProInfo WHERE Number = " . $Team ;
$TeamName = $db->querySingle($MainQuery);
$PlayerQuery = "SELECT * FROM PlayerInfo WHERE TeamName = " . $TeamName;
$PlayerInfo = $db->query($PlayerQuery);

I then get errors like this:
Warning: SQLite3::query(): Unable to prepare statement: 1, near "Bruins": syntax error in C:\xampp\htdocs\TestSite\Templates\Roster.php on line 335 which points to the $PlayerInfo line.

I can echo out the $TeamName element and it does echo the team name correctly, in this case Boston Bruins. It just doesn't seem to be able to use that to filter out the players from the PlayerInfo table?