Page 1 of 1
Questions regarding PHP Coding
Posted: Thu Sep 09, 2004 9:47 am
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
Posted: Thu Sep 09, 2004 10:09 am
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.
Posted: Thu Sep 09, 2004 10:17 am
by CoderGoblin
Answer 2 : Not directly from Excel to X using PHP.... Normally people save the Excel as a CSV file for processing...
Posted: Thu Sep 09, 2004 10:25 am
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
Posted: Thu Sep 09, 2004 11:17 am
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
Posted: Thu Sep 09, 2004 2:23 pm
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
Posted: Thu Sep 09, 2004 5:04 pm
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....
Posted: Thu Sep 09, 2004 5:11 pm
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.
Posted: Thu Sep 09, 2004 5:39 pm
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

)
Posted: Fri Sep 10, 2004 8:29 am
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
Posted: Fri Sep 10, 2004 9:28 am
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