Trying to setup PHP Template Website

If you need help building your website, this is the place to hang out. If you're an HTML, PHP, Perl or web database geek, check it out. / Si vous avez besoin d'aide pour construire votre site web, c'est le forum à regarder! Si vous êtes un expert en HTML, PHP, Perl ou en base de données, c'est le forum pour vous!
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Trying to setup PHP Template Website

Post 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.
SimonT
STHS Owner / Propriétaire du STHS
Posts: 14757
Joined: Sat Oct 08, 2005 4:18 pm
Location: Montreal, Canada
Contact:

Re: Trying to setup PHP Template Website

Post 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.
-SimonT
Forum Administrator / Administrateur du Forum
STHS Owner / Propriètaire du STHS
English V2 & V3 Manual - Manuel V2 & V3 Français
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Trying to setup PHP Template Website

Post 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?
SimonT
STHS Owner / Propriétaire du STHS
Posts: 14757
Joined: Sat Oct 08, 2005 4:18 pm
Location: Montreal, Canada
Contact:

Re: Trying to setup PHP Template Website

Post 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.
-SimonT
Forum Administrator / Administrateur du Forum
STHS Owner / Propriètaire du STHS
English V2 & V3 Manual - Manuel V2 & V3 Français
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Trying to setup PHP Template Website

Post by Bmoney0313 »

What's the best email address to reach you at?
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Trying to setup PHP Template Website

Post by Bmoney0313 »

Actually can I output a DB from the v2 demo?
SimonT
STHS Owner / Propriétaire du STHS
Posts: 14757
Joined: Sat Oct 08, 2005 4:18 pm
Location: Montreal, Canada
Contact:

Re: Trying to setup PHP Template Website

Post by SimonT »

I think you can! Good thinking!
-SimonT
Forum Administrator / Administrateur du Forum
STHS Owner / Propriètaire du STHS
English V2 & V3 Manual - Manuel V2 & V3 Français
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Trying to setup PHP Template Website

Post 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?
SimonT
STHS Owner / Propriétaire du STHS
Posts: 14757
Joined: Sat Oct 08, 2005 4:18 pm
Location: Montreal, Canada
Contact:

Re: Trying to setup PHP Template Website

Post by SimonT »

Try with this syntaxes

PlayerInfo.php?Player=2

I had the information in GitHub also.
-SimonT
Forum Administrator / Administrateur du Forum
STHS Owner / Propriètaire du STHS
English V2 & V3 Manual - Manuel V2 & V3 Français
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Trying to setup PHP Template Website

Post 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?
SimonT
STHS Owner / Propriétaire du STHS
Posts: 14757
Joined: Sat Oct 08, 2005 4:18 pm
Location: Montreal, Canada
Contact:

Re: Trying to setup PHP Template Website

Post 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.
-SimonT
Forum Administrator / Administrateur du Forum
STHS Owner / Propriètaire du STHS
English V2 & V3 Manual - Manuel V2 & V3 Français
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Trying to setup PHP Template Website

Post by Bmoney0313 »

Understood. Thanks for the assistance so far.
Foo
The SuperStar
Posts: 1566
Joined: Thu Dec 29, 2005 12:56 pm

Re: Trying to setup PHP Template Website

Post 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...
Image
Image
Image
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Trying to setup PHP Template Website

Post 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.
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Trying to setup PHP Template Website

Post 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?
Post Reply