Questions regarding PHP Coding

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpcoder1
Forum Newbie
Posts: 3
Joined: Thu Sep 09, 2004 9:15 am

Questions regarding PHP Coding

Post by phpcoder1 »

Hi Everyone !

I am kind of novice in PHP coding.. have been doing it on and off.. but now want to learn it in more detail. I have some general questions regarding PHP language and would be thankful who can answer it for me.

So here it goes:
1) In PHP what is more efficient to use - Switch-case , If-Else, Do-While for efficient coding ?
2) Is it possible to import data from Excelsheets into Oracle database using PHP ?
3) If I needed to use PHP for Graph plotting.. what are the pros and cons for that ?

Thanks in advance
AB
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

1) There all pretty efficient so i would say its more down to personal preference and using whatever makes the code more readable - dont use 10 if-else statements when you can use a switch. Use do-while if you always want it to be run at least once.

2) Yeah its possible to do pretty much everything as long as you work your way through the problem. You would just parse the file and insert it into the database.

3) You can use the graphics library to draw - so yeah. Pros - you could create dynamic graphs on web pages. Cons - it would probably take a while to code and be not very efficent.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Answer 2 : Not directly from Excel to X using PHP.... Normally people save the Excel as a CSV file for processing...
phpcoder1
Forum Newbie
Posts: 3
Joined: Thu Sep 09, 2004 9:15 am

Post by phpcoder1 »

Thanks for your reply.

Its really helpful to know all this.

Now CoderGoblin, as you have said not directly, we are talking about converting the excel data sheet into a comma delimited (or any other delimited) format and then putting the data in the database. So is there a way PHP can do the conversion of excel-CSV conversion within the code ?

Hey Kettle_Drum thanks for your reply.

Can you suggest any document/tutorial/book that might be helpful in doing this tasks if you know of any ?

Thanks in advance.
AB
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

As long as you know how excel stores the data then you can do it straight from the xls file, if not just do a save as from excel into whatever other format you want - e.g. a csv
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

And the last question: graphs in php
you would need imagemagick, gd(2) or the like..


some scripts that i like:
http://quimby.gnus.org/circus/chart/chart-manual.php
http://www.ruistech.com/phpBarGraph
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

you can use GD or similar libraries for php to make graphs, in my opinion there are no pros to using GD, its a pain in the butt in my opinion to get it all to fit together like you want, and the cons well, its image creation on the fly, this is all done on the server so 1. it will slow the webserver down in a whole because if you have a high page view rate then everytime someone views the page the server has to redraw the image so it consumes server resources very quick, tried making a game using gd on a petsite i program for but with over 8000 users many of whom play the game very frequently brought the server to a hault. it also will consume bandwidth moreso then a static image, because normally a static image is cached where as a dynamic image normally is reloaded at every page referesh

well...those were my 2 cents....
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

dull1554 wrote: it also will consume bandwidth moreso then a static image, because normally a static image is cached where as a dynamic image normally is reloaded at every page referesh
you can use standard HTTP Caching to reduce badwidth usage.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

At least the 2 scripts i mentionned also offer the ability to write the generated image to a file (so they can be cached easily :))
phpcoder1
Forum Newbie
Posts: 3
Joined: Thu Sep 09, 2004 9:15 am

Post by phpcoder1 »

Thanks everyone for your replies, it is really good to know all this.

So , so far what we have discussed I am getting a feel that plotting graphs is not a very good combination with PHP.

Would doing the same in any other coding language be recommended ? If so, is it possible to embede that code in PHP ?

Thanks in advance
AB
Breckenridge
Forum Commoner
Posts: 62
Joined: Thu Sep 09, 2004 11:10 pm
Location: Breckenridge, Colorado

Post by Breckenridge »

You should be able to accomplish all that you wish with php. it's fast and efficient and there is no need for you to do anything but visit http://www.php.net and get to know php commands that help your quest.

I've been doing it for years and will not switch to any other scripting languages
Post Reply