Re: [PHP] php as CGI and $_POST
David T-G wrote: Peter -- ...and then Peter Risdon said... % % David T-G wrote: % % bash-2.05a$ /usr/local/bin/php -v % PHP 4.3.4 (cli) (built: Jan 6 2004 15:27:52) % % You probably need the cgi version - not the command line one you % actually have. Ooohhh... Ouch. So there are *three* possible PHP compiles: module, CGI, and CLI? So far as the php binary in /usr/local/bin is concerned there are two - cli and cgi. The module consists of different files (see the AddModule and LoadModule bits of httpd.conf). You can have both (I have made that my standard build for multi-homed machines) but need to muck about a bit for this. OK. To save us the cost of rebuilding at this host, is there any way to pass args to the CLI version of the script running as a CGI? You might find you start getting odd problems with http headers if you use the cli version. In general you're better off using the cgi one. But you can get this by recompiling but not installing php cgi, then copy the php executable to, say, /usr/local/bin/php-cgi and prefacing your scripts with this in the shebang. That would mean zero disruption for users on the machine. Peter. Thanks HAND :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: if/elseif/else v. switch
This appears to be a really, really stupid question. If they are indentical in operation, then ofcourse there will be no noticeable difference to the user. One may note that a switch statement is faster, because the condition is only evaluated once. However you did not ask about the speed difference. Dennis Seavers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is there any noticeable difference (on the part of the client) between identical conditionals, one written as a switch, the other written as an if, elseif ... else conditional? I realize that one programmer coming in behind another might prefer the gentler layout of a switch; but would there be any perceivable difference, client-side, between the options? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if/elseif/else v. switch
--- Aidan Lister [EMAIL PROTECTED] wrote: This appears to be a really, really stupid question. Is this level of condemnation of a poster necessary? Whether you think Dennis's question was stupid or not, there is no need for such harsh criticism in front of everyone on this list. There are many ways you could have worded your response to ask the poster to rephrase his question. Your approach was not appropriate. = ~Rachel __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] generating graphs
Hi all, Please help me in this. How can I generate bar charts etc with PHP? Thanks in advance
Re: [PHP] generating graphs
Nitin wrote: Hi all, Please help me in this. How can I generate bar charts etc with PHP? Thanks in advance http://www.aditus.nu/jpgraph/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if/elseif/else v. switch
Hi Rachel, You'll note I did not criticise the poster, merely his seemingly stupid question. I suggest you practice what you preach. If you have a comment on my reply to a users post, feel free to contact me personally - [EMAIL PROTECTED] There is equally no need to criticise my crticism - on the list, in front of everyone, as you so boldly put it. Rachel Rodriguez [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] --- Aidan Lister [EMAIL PROTECTED] wrote: This appears to be a really, really stupid question. Is this level of condemnation of a poster necessary? Whether you think Dennis's question was stupid or not, there is no need for such harsh criticism in front of everyone on this list. There are many ways you could have worded your response to ask the poster to rephrase his question. Your approach was not appropriate. = ~Rachel __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if/elseif/else v. switch
Now Now children ... It is always worth remembering that for some posters English is not their first language and therefore while a question may sound silly, there may be perfectly good reasons for it being asked. Always answer the bits that fit between the lines, that is usually the real question. Returning to the question :) If a case statement can be created with a switch, then that should be faster than a string of if then's, but I have seen compilers converting a set of switch values to a string of if then statement like checks. So internally there may well be no difference what so ever! But where a number of conditions need checking, then the result may not be practical with a simple switch anyway. So the question is possibly - does a case statement switch get processed as a set of goto statements, or a list of equality checks? It makes no difference to the client, but would have an effect on processing times and perhaps the order of segments could be adjusted to account for the most likely state first. -- Lester Caine - L.S.Caine Electronic Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generating graphs
thanks for the help, but my PHP ver is 4.0.6... Any other suggestions?? - Original Message - From: Ryszard Hapka [EMAIL PROTECTED] To: Nitin [EMAIL PROTECTED] Cc: PHP List [EMAIL PROTECTED] Sent: Saturday, June 05, 2004 6:11 PM Subject: Re: [PHP] generating graphs Nitin wrote: Hi all, Please help me in this. How can I generate bar charts etc with PHP? Thanks in advance http://www.aditus.nu/jpgraph/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] row colours
this piece of script makes alternate row colours, but i want the rows to be coloured in blocks of 8. So the first 8 rows are white then the next are mauve etc etc. Alternatively i could make the rows all the same colour , but i need a blank row after each 8 rows.? Any ideas -- if ($i%8 == 0) { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; } else { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; } --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Refresh Page
I want to refresh page every 10 seconds, without clicking on Refresh button. Any ideas how this can be done? Thanks _ MSN 9 Dial-up Internet Access fights spam and pop-ups now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Refresh Page
meta http-equiv=refresh content=10; url=test.php Put inside the HEAD tags, this refreshed the page every 10 seconds. I want to refresh page every 10 seconds, without clicking on Refresh button. Any ideas how this can be done? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generating graphs
On Sat, 5 Jun 2004 19:31:34 +0530 [EMAIL PROTECTED] (Nitin) wrote: thanks for the help, but my PHP ver is 4.0.6... Any other suggestions?? hmm, upgrade? :) really, its worth it! thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Refresh Page
On Sat, 2004-06-05 at 10:20, Mike Mapsnac wrote: I want to refresh page every 10 seconds, without clicking on Refresh button. Any ideas how this can be done? Thanks I think you want to include something like this in your pages header section: META HTTP-EQUIV=REFRESH CONTENT=10 -- Scot L. Harris [EMAIL PROTECTED] It is so soon that I am done for, I wonder what I was begun for. -- Epitaph, Cheltenham Churchyard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] row colours
BigMark wrote: this piece of script makes alternate row colours, but i want the rows to be coloured in blocks of 8. So the first 8 rows are white then the next are mauve etc etc. Alternatively i could make the rows all the same colour , but i need a blank row after each 8 rows.? Any ideas -- untested: if($i % 16 8) // if ($i%8 == 0) { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; } else { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; } --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] row colours
On Sat, Jun 05, 2004 at 04:54:33PM +0200, Marek Kilimajer wrote: BigMark wrote: this piece of script makes alternate row colours, but i want the rows to be coloured in blocks of 8. So the first 8 rows are white then the next are mauve etc etc. Alternatively i could make the rows all the same colour , but i need a blank row after each 8 rows.? Any ideas -- How about: $bgcolor = ($i % 16 8) ? #ff : #ff; print tr bgcolor='$bgcolor'td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; // if ($i%8 == 0) { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; } else { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; } --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net --- Duty then is the sublimest word in the English language. You should do your duty in all things. You can never do more, you should never wish to do less. -- General Robert E. Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Refresh Page
You can use javascript timer that are much more flexible than META HTTP-EQUIV=REFRESH because you can test for conditions, etc. Mike Mapsnac [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] I want to refresh page every 10 seconds, without clicking on Refresh button. Any ideas how this can be done? Thanks _ MSN 9 Dial-up Internet Access fights spam and pop-ups - now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Coloured rows
Yeah, you have $number which is the total number of rows, right? so just change the if piece to actually count... $j = 0; while ($i = $number){ //first 8 rows done here if ($j = 8) { //print statement here $j++; $i++; } //this piece does the next 8 rows else { //other print statement here $j++; $i++; // if you have more then 16 rows // this next piece should make it repeat the if statement // without having to do too much funky stuff in them if ($j = 16) {$j = 0;} } } Hi robert, any way of making the script you sent to me, colour 8 rows in one colour then the next 8 rows a different colour. Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DB Query
I'm trying to optimize a query that in the first example is taking too long to run. This is my existing working query: $sql = SELECT count(*) as cnt, id FROM `mYTable` WHERE c1 not in (1,16,36) and c2 not in (1,16,36) and c3 not in (1,16,36) and c4 not in (1,16,36) and c5 not in (1,16,36) GROUP BY id; Is it possible to do something like this instead (This doesn't work of course) $sql = SELECT count(*) as cnt, id FROM `myTable` WHERE (c1,c2,c3,c4,c5) not in (1,16,36) GROUP BY id; Any other suggestions are appreciated, Thanks!
Re: [PHP] Re: Refresh Page
I've used this META tag is IF statement conditionals in the header too. Works well NOT to refresh when in a edit mode. You can use javascript timer that are much more flexible than META HTTP-EQUIV=REFRESH because you can test for conditions, etc. Mike Mapsnac [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] I want to refresh page every 10 seconds, without clicking on Refresh button. Any ideas how this can be done?
Re: [PHP] DB Query
Run an explain plan, but my first quess would be to add indexes to c1, c2, c3, c4, c5 fields. I'm trying to optimize a query that in the first example is taking too long to run. This is my existing working query: $sql = SELECT count(*) as cnt, id FROM `mYTable` WHERE c1 not in (1,16,36) and c2 not in (1,16,36) and c3 not in (1,16,36) and c4 not in (1,16,36) and c5 not in (1,16,36) GROUP BY id; Is it possible to do something like this instead (This doesn't work of course) $sql = SELECT count(*) as cnt, id FROM `myTable` WHERE (c1,c2,c3,c4,c5) not in (1,16,36) GROUP BY id; Any other suggestions are appreciated, Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Prevent IE6 from blocking cookies
Do I a prevent Internet Explorer 6 from blocking cookies (session cookies, etc)? Do I have to setup something in the META HEADERS? Thanks Robert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prevent IE6 from blocking cookies
On Sat, 2004-06-05 at 11:55, Robert Winter wrote: Do I a prevent Internet Explorer 6 from blocking cookies (session cookies, etc)? Do I have to setup something in the META HEADERS? Thanks Robert I don't think you can override that from a web page. If the user is blocking cookies then the best you can do is show an alternate page telling the user they need to enable cookies to work with your web site. Face it, if web sites could override such settings there would be a lot more malicious web sites out there. -- Scot L. Harris [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] shedule a php script
hi friends , when running this php script we can make a log file with relavent to the mysql data base. but i need to executethis script after every 2 min time. that is mean theremust be a 2 min sleep time . can somebody help medo this function plz .? ?php require ('connectMySql.php'); $select= " select ServiceNo, ServiceName, Status, DateTime from ServiceStatus "; $add_member = $db_object-query($select); $result=mysql_query($select); while($row=mysql_fetch_array ($result)) { $output1 =$row['ServiceNo']; $output2 =$row['ServiceName']; $output3 =$row['Status']; $output4 =$row['DateTime']; $your_data .= " $output1.\t $output2 - $output3 - $output4 \n"; $output = "$your_data \n"; } // Open the file and erase the contents if any$fp = fopen("vas_status.log", "a"); // Write the data to the filefwrite($fp, $output); // Close the filefclose($fp); if (DB::isError($add_member)) { die($add_member-getMessage()); } $db_object-disconnect(); ? thanx in advance curlys -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: shedule a php script
If you're on a Unix-like system, add the following at the top of your script: #!/usr/local/bin/php Of course, modify the path to the location of your php binary, since it may not be in the same location. Then, make the file executable with: chmod +x filename.php Then, create a cron job to run the script however often you want. Curlybraces Technologies Ltd wrote: hi friends , when running this php script we can make a log file with relavent to the mysql data base. but i need to execute this script after every 2 min time. that is mean there must be a 2 min sleep time . can somebody help me do this function plz .? ?php require ('connectMySql.php'); $select= select ServiceNo, ServiceName, Status, DateTime from ServiceStatus ; $add_member = $db_object-query($select); $result=mysql_query($select); while($row=mysql_fetch_array ($result)) { $output1 =$row['ServiceNo']; $output2 =$row['ServiceName']; $output3 =$row['Status']; $output4 =$row['DateTime']; $your_data .= $output1.\t $output2 - $output3 - $output4 \n; $output = $your_data \n; } // Open the file and erase the contents if any $fp = fopen(vas_status.log, a); // Write the data to the file fwrite($fp, $output); // Close the file fclose($fp); if (DB::isError($add_member)) { die($add_member-getMessage()); } $db_object-disconnect(); ? thanx in advance curlys -- Regards, Ben Ramsey http://benramsey.com --- http://www.phpcommunity.org/ Open Source, Open Community Visit for more information or to join the movement. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] DB Query
Explain plan? Due to the number of records, any indexes I added have significantly delayed the query. -Original Message- From: Daniel Clark [mailto:[EMAIL PROTECTED] Sent: Saturday, June 05, 2004 11:41 AM To: bskolb; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] DB Query Run an explain plan, but my first quess would be to add indexes to c1, c2, c3, c4, c5 fields. I'm trying to optimize a query that in the first example is taking too long to run. This is my existing working query: $sql = SELECT count(*) as cnt, id FROM `mYTable` WHERE c1 not in (1,16,36) and c2 not in (1,16,36) and c3 not in (1,16,36) and c4 not in (1,16,36) and c5 not in (1,16,36) GROUP BY id; Is it possible to do something like this instead (This doesn't work of course) $sql = SELECT count(*) as cnt, id FROM `myTable` WHERE (c1,c2,c3,c4,c5) not in (1,16,36) GROUP BY id; Any other suggestions are appreciated, Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] row colours
On Sat, 2004-06-05 at 11:21, James Kaufman wrote: $bgcolor = ($i % 16 8) ? #ff : #ff; print tr bgcolor='$bgcolor'td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; You probably want to do: $bgcolor = (($i % 16) 7) ? #ff : #ff; Since $i % 16 will rotate from 0 - 15. This will work assuming $i starts at 0. If not then you should do: $bgcolor = ((($i - $x) % 16) 7) ? #ff : #ff; Where $x is whatever value $i started at. However, I would recommend using a new counter that starts a 0 and is incremented at the end of your loop. Alternatively you could do: print tr bgcolor='#ff'td$item_1/tdtd$item_2/tdtd$item_4/tdtdcenter$item_5/center/td/tr\n; if ($i % 8 == 7) { print trtd colspan='4'/td/tr\n; } which would keep them the same color and add a blank row after every eighth; again adjust $i as necessary to fit. -- Adam Bregenzer [EMAIL PROTECTED] http://adam.bregenzer.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: shedule a php script
I would recommend the cronjob too but if you want to just keep the script running, do a while-loop around your code, i.e. while(1) { ... your code sleep(120); // sleep 120 seconds } --- the require should be outside of the loop IMHO ;). thomas On Sat, 5 Jun 2004 21:46:20 +0600 [EMAIL PROTECTED] (Curlybraces Technologies \ Ltd) wrote: hi friends , when running this php script we can make a log file with relavent to the mysql data base. but i need to execute this script after every 2 min time. that is mean there must be a 2 min sleep time . can somebody help me do this function plz .? ?php require ('connectMySql.php'); $select= select ServiceNo, ServiceName, Status, DateTime from ServiceStatus ; $add_member = $db_object-query($select); $result=mysql_query($select); while($row=mysql_fetch_array ($result)) { $output1 =$row['ServiceNo']; $output2 =$row['ServiceName']; $output3 =$row['Status']; $output4 =$row['DateTime']; $your_data .= $output1.\t $output2 - $output3 - $output4 \n; $output = $your_data \n; } // Open the file and erase the contents if any $fp = fopen(vas_status.log, a); // Write the data to the file fwrite($fp, $output); // Close the file fclose($fp); if (DB::isError($add_member)) { die($add_member-getMessage()); } $db_object-disconnect(); ? thanx in advance curlys -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] moderators?
Not sure this has been discussed previously or if this is new. It appears that when you send a message to the list there are two messages sent back to the sender. One appears to be a user that no longer exists. That user is [EMAIL PROTECTED] The other one also appears to be an Unknown user: [EMAIL PROTECTED] If there is a moderator can these two accounts be removed from the list? -- Scot L. Harris [EMAIL PROTECTED] Disobedience: The silver lining to the cloud of servitude. -- Ambrose Bierce -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: row colours-- thanks!
Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: shedule a php script/ plz help
I've got to run, so I don't have time to reply to this. I am instead posting it to the list so that others may help you. In the future, keep your posts on the list so that others can benefit or help you. :-) CurlyBraces Technologies ( Pvt ) Ltd wrote: yes, i did as u said .., i have added that file into the /etc/cron.d , directory also vi /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly * * * * * root run-parts /etc/cron.d/abc.php am i correct , plz help me ..but it is still not running ? thank u - Original Message - From: Ben Ramsey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, June 05, 2004 10:07 PM Subject: [PHP] Re: shedule a php script If you're on a Unix-like system, add the following at the top of your script: #!/usr/local/bin/php Of course, modify the path to the location of your php binary, since it may not be in the same location. Then, make the file executable with: chmod +x filename.php Then, create a cron job to run the script however often you want. Curlybraces Technologies Ltd wrote: hi friends , when running this php script we can make a log file with relavent to the mysql data base. but i need to execute this script after every 2 min time. that is mean there must be a 2 min sleep time . can somebody help me do this function plz .? ?php require ('connectMySql.php'); $select= select ServiceNo, ServiceName, Status, DateTime from ServiceStatus ; $add_member = $db_object-query($select); $result=mysql_query($select); while($row=mysql_fetch_array ($result)) { $output1 =$row['ServiceNo']; $output2 =$row['ServiceName']; $output3 =$row['Status']; $output4 =$row['DateTime']; $your_data .= $output1.\t $output2 - $output3 - $output4 \n; $output = $your_data \n; } // Open the file and erase the contents if any $fp = fopen(vas_status.log, a); // Write the data to the file fwrite($fp, $output); // Close the file fclose($fp); if (DB::isError($add_member)) { die($add_member-getMessage()); } $db_object-disconnect(); ? thanx in advance curlys -- Regards, Ben Ramsey http://benramsey.com --- http://www.phpcommunity.org/ Open Source, Open Community Visit for more information or to join the movement. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards, Ben Ramsey http://benramsey.com --- http://www.phpcommunity.org/ Open Source, Open Community Visit for more information or to join the movement. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: shedule a php script
Thomas Seifert wrote: I would recommend the cronjob too but if you want to just keep the script running, do a while-loop around your code, i.e. while(1) { ... your code sleep(120); // sleep 120 seconds } --- the require should be outside of the loop IMHO ;). Or if you want to run the script from the browser, use meta-refresh, see Refresh Page thread on this list. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prevent IE6 from blocking cookies
* and then Scot L. Harris declared Face it, if web sites could override such settings there would be a lot more malicious web sites out there. Absolutely. You cant mess with peoples preffered settings. It's EVIL ;-) Best you can do is make provision for those without cookies enabled: Use JS, if (cookies are enabled) { set the damn coookie } else { use sessions... } -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DB Query
bskolb wrote: I'm trying to optimize a query that in the first example is taking too long to run. This is my existing working query: $sql = SELECT count(*) as cnt, id FROM `mYTable` WHERE c1 not in (1,16,36) and c2 not in (1,16,36) and c3 not in (1,16,36) and c4 not in (1,16,36) and c5 not in (1,16,36) GROUP BY id; Is it possible to do something like this instead (This doesn't work of course) $sql = SELECT count(*) as cnt, id FROM `myTable` WHERE (c1,c2,c3,c4,c5) not in (1,16,36) GROUP BY id; Any other suggestions are appreciated, Thanks! Even if the syntax whould be possible, it whould not help any. SQL server optimize queries before executing them, and your second query would be the same as the first one. What is the column type of c1,c2,c3,c4 and c5? What indexes did you create? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP User Interface
I've been working with PHP for a few years now. I like doing the real programming that really does something, but I find I'm wasting a great deal of time working with UI via HTML. Are there any setups (classes, functions, etc) for PHP that drastically streamline working with the UI? Especially form-related things, it's really annoying to deal with. Also security is another concern, having to double check that the contents of the form submit (i.e. menu) are valid and include what you handed out in the first place can be very obnoxious! I know I could code something to accelerate this process, but before I look at doing this (and spend hours upon hours doing it), I want to check and see that nothing else is already out there. Thoughts anybody? -Galen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: shedule a php script/ plz help
yes, i did as u said .., i have added that file into the /etc/cron.d , directory also vi /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly * * * * * root run-parts /etc/cron.d/abc.php am i correct , plz help me ..but it is still not running ? thank u - Original Message - From: Ben Ramsey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, June 05, 2004 10:07 PM Subject: [PHP] Re: shedule a php script If you're on a Unix-like system, add the following at the top of your script: #!/usr/local/bin/php Of course, modify the path to the location of your php binary, since it may not be in the same location. Then, make the file executable with: chmod +x filename.php Then, create a cron job to run the script however often you want. Curlybraces Technologies Ltd wrote: hi friends , when running this php script we can make a log file with relavent to the mysql data base. but i need to execute this script after every 2 min time. that is mean there must be a 2 min sleep time . can somebody help me do this function plz .? ?php require ('connectMySql.php'); $select= select ServiceNo, ServiceName, Status, DateTime from ServiceStatus ; $add_member = $db_object-query($select); $result=mysql_query($select); while($row=mysql_fetch_array ($result)) { $output1 =$row['ServiceNo']; $output2 =$row['ServiceName']; $output3 =$row['Status']; $output4 =$row['DateTime']; $your_data .= $output1.\t $output2 - $output3 - $output4 \n; $output = $your_data \n; } // Open the file and erase the contents if any $fp = fopen(vas_status.log, a); // Write the data to the file fwrite($fp, $output); // Close the file fclose($fp); if (DB::isError($add_member)) { die($add_member-getMessage()); } $db_object-disconnect(); ? thanx in advance curlys -- Regards, Ben Ramsey http://benramsey.com --- http://www.phpcommunity.org/ Open Source, Open Community Visit for more information or to join the movement. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP User Interface
Galen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I've been working with PHP for a few years now. I like doing the real programming that really does something, but I find I'm wasting a great deal of time working with UI via HTML. Are there any setups (classes, functions, etc) for PHP that drastically streamline working with the UI? Especially form-related things, it's really annoying to deal with. Also security is another concern, having to double check that the contents of the form submit (i.e. menu) are valid and include what you handed out in the first place can be very obnoxious! I know I could code something to accelerate this process, but before I look at doing this (and spend hours upon hours doing it), I want to check and see that nothing else is already out there. Thoughts anybody? Hi Galen, there are several PEAR classes that aid form building, processing and so on. Take a look at the HTML_QuickForm and HTML_QuickForm_Controller classes: http://pear.php.net/package/HTML_QuickForm http://pear.php.net/package/HTML_QuickForm_Controller There is also a Validate class for checking all types of input values: http://pear.php.net/package/Validate Of course it will take some time to get into it but will save you a lot of time in future projects. Hope this helps! Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: shedule a php script
alright , thank u very much, i successfully run with that while loop . it is working. so thank u , very much curlys - Original Message - From: Marek Kilimajer [EMAIL PROTECTED] To: Thomas Seifert [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, June 05, 2004 10:49 PM Subject: Re: [PHP] Re: shedule a php script Thomas Seifert wrote: I would recommend the cronjob too but if you want to just keep the script running, do a while-loop around your code, i.e. while(1) { ... your code sleep(120); // sleep 120 seconds } --- the require should be outside of the loop IMHO ;). Or if you want to run the script from the browser, use meta-refresh, see Refresh Page thread on this list. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prevent IE6 from blocking cookies
Nick Wilson wrote: * and then Scot L. Harris declared Face it, if web sites could override such settings there would be a lot more malicious web sites out there. Absolutely. You cant mess with peoples preffered settings. It's EVIL ;-) Best you can do is make provision for those without cookies enabled: Use JS, if (cookies are enabled) { set the damn coookie } else { use sessions... } Of course, sessions use cookies, so that won't work either. ;-) You *can* use URL rewriting to have PHP add the session ID to all of your urls and forms, but this isn't fool-proof. If you really want to support non-cookie sessions, you have to add the session id to all of your urls and forms yourself. -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] DB Query
My first query was: $sql = 'SELECT count(*) as cnt,id FROM `myTable` WHERE c11 and c21 and c31 and c41 and c51 and c116 and c216 and c316 and c416 and c516 and c136 and c236 and c336 and c436 and c536 GROUP BY id'; By using the IN statement, it reduced my query time by 24%, and is why I was inquiring about my second option. There are only 6 columns, all TinyInt. Indexing any single, multiple or all columns had no noticeable change in querys execution time. FYI, there are some 3 million records. -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED] Sent: Saturday, June 05, 2004 12:56 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] DB Query bskolb wrote: I'm trying to optimize a query that in the first example is taking too long to run. This is my existing working query: $sql = SELECT count(*) as cnt, id FROM `mYTable` WHERE c1 not in (1,16,36) and c2 not in (1,16,36) and c3 not in (1,16,36) and c4 not in (1,16,36) and c5 not in (1,16,36) GROUP BY id; Is it possible to do something like this instead (This doesn't work of course) $sql = SELECT count(*) as cnt, id FROM `myTable` WHERE (c1,c2,c3,c4,c5) not in (1,16,36) GROUP BY id; Any other suggestions are appreciated, Thanks! Even if the syntax whould be possible, it whould not help any. SQL server optimize queries before executing them, and your second query would be the same as the first one. What is the column type of c1,c2,c3,c4 and c5? What indexes did you create? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if/elseif/else v. switch
* Thus wrote Dennis Seavers ([EMAIL PROTECTED]): Is there any noticeable difference (on the part of the client) ... The only time the client will perhaps notice a difference is if your condition is in a loop that cycles a couple thousand times or more. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if/elseif/else v. switch
* Thus wrote Aidan Lister ([EMAIL PROTECTED]): This appears to be a really, really stupid question. Didn't your teachers ever tell you that there is no such thing as a stupid question? Curt -- What... is the Airspeed Velocity of an Unladen Swallow? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie question about good coding practice [isset]
if($var) do something; verses if(isset($var)) do something; The simple form if($var) seems to work fine and I see it in code often. Is there a good reason for using isset? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about good coding practice [isset]
if($var) do something; verses if(isset($var)) do something; The simple form if($var) seems to work fine and I see it in code often. Is there a good reason for using isset? Yes, if you don't use isset(), you may see notices (errors) if the variable is not set. This depends upon the error reporting settings of the server. However, if you use isset() you won't see notices regardless. Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about good coding practice [isset]
When $var is 0? ? $var = 0; // Output: $var: $var not exists if ( $var ) echo '$var: $var existsbr'; else echo '$var: $var not existsbr'; // Output: isset(): var exists if ( isset($var) ) echo 'isset(): $var existsbr'; else echo 'isset(): $var not existsbr'; ? Larry E . Ullman wrote: if($var) do something; verses if(isset($var)) do something; The simple form if($var) seems to work fine and I see it in code often. Is there a good reason for using isset? Yes, if you don't use isset(), you may see notices (errors) if the variable is not set. This depends upon the error reporting settings of the server. However, if you use isset() you won't see notices regardless. Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DB Query
* Thus wrote bskolb ([EMAIL PROTECTED]): I'm trying to optimize a query that in the first example is taking too long to run. This is my existing working query: $sql = SELECT count(*) as cnt, id FROM `mYTable` WHERE c1 not in (1,16,36) and c2 not in (1,16,36) and c3 not in (1,16,36) and c4 not in (1,16,36) and c5 not in (1,16,36) GROUP BY id; Is it possible to do something like this instead (This doesn't work of course) $sql = SELECT count(*) as cnt, id FROM `myTable` WHERE (c1,c2,c3,c4,c5) not in (1,16,36) GROUP BY id; Any other suggestions are appreciated, No matter what you do either a 'not in ()' or '', mysql is going to have to do a table scan for all the records. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prevent IE6 from blocking cookies
* Thus wrote Justin Patrin ([EMAIL PROTECTED]): Nick Wilson wrote: * and then Scot L. Harris declared Face it, if web sites could override such settings there would be a lot more malicious web sites out there. Absolutely. You cant mess with peoples preffered settings. It's EVIL ;-) Best you can do is make provision for those without cookies enabled: Use JS, if (cookies are enabled) { set the damn coookie } else { use sessions... } Of course, sessions use cookies, so that won't work either. ;-) You *can* use URL rewriting to have PHP add the session ID to all of your urls and forms, but this isn't fool-proof. If you really want to support non-cookie sessions, you have to add the session id to all of your urls and forms yourself. transid helps this a bit. Its possible to enable both cookie/transid methods together. The trick is finding out on the first request which method is going to be used. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about good coding practice [isset]
* Thus wrote K.Bogac Bokeer ([EMAIL PROTECTED]): When $var is 0? ? $var = 0; or $var = ''; $var = array(); $var = false; // Output: $var: $var not exists if ( $var ) echo '$var: $var existsbr'; else Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] moderators?
* Thus wrote Scot L. Harris ([EMAIL PROTECTED]): Not sure this has been discussed previously or if this is new. It appears that when you send a message to the list there are two messages sent back to the sender. One appears to be a user that no longer exists. That user is [EMAIL PROTECTED] The other one also appears to be an Unknown user: [EMAIL PROTECTED] If there is a moderator can these two accounts be removed from the list? Sorry, but I cant send mail directly, rr wont let me send mail to anyone over there, so I'll reply via the list... You can Fwd the bouncing messages headers to here: [EMAIL PROTECTED] I've already sent a message regarging the [EMAIL PROTECTED] address. I dont seem to be getting the learn2prog@ messages. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Error Downloading files using FOpen
Gerald Winkler wrote: snip The code for the fopen is specifying a binary d/l and not ASCII so it shouldn't be doing this... /snip ...Or should it?.. snip Oh, it was originally tested using some .xls files, but a few .txt files I created as a test were altered in the d/l as well... /snip It works with the .xls files, but not with the .txt file correct? .xls files are binary, .txt files are ASCII To open the .txt file try one of these instead $fd = fopen($filepath,'r'); or $fd = fopen($filepath,'rt'); Of course another infamous snip from the manual... http://www.php.net/fopen snip The default translation mode depends on the SAPI and version of PHP that you are using, so you are encouraged to always specify the appropriate flag for portability reasons. You should use the 't' mode if you are working with plain-text files and you use \n to delimit your line endings in your script, but expect your files to be readable with applications such as notepad. You should use the 'b' in all other cases. /snip Hope that helps. Sorry if I misunderstood your problem. -- Chris Martin Web Developer Open Source Web Standards Advocate http://www.chriscodes.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Garbage Collection (session.gc_maxlifetime)
Do I need to change the session.save_path directive for each virtual host to use their own directory other than the system and/or PHP default (/tmp) in order to effectively override each virtual host session.gc_maxlifetime directive? Let me offer an example for clarification. Example: A shared hosting provider has 10 domains running on an Apache server with PHP. www.shared_host1.com wants to set his session.gc_maxlifetime to 60 minutes. To do so, he must either use ini_set or a PER_DIRECTORY override file (.htaccess) to change the default directive setting of 1440 (24 minutes) to 3600. Now www.shared_host2.com wants to use sessions as well, but decides that a ten hour setting would be ideal, so www.shared_host2.com alters the directive in the same manner, setting the value to 36000. Now we know that ini_set is going to keep this new value during the script's execution, and will be restored at the script's ending, and a .htaccess file would work the same way. We also know (by opening and viewing the contents of a session file in the /tmp directory) that there is nothing in the file itself that designates when it will expire, PHP merely looks at the file mtime (atime, if PHP 4.2.3). What I mean by this is that PHP doesn't look at the mtime of the file and compare it with some internal value to figure out if it should be trashed. If both hosts sessions are being written and saved in the default directory (/tmp), then I am assuming the session directives of the current session request determine whether or not garbage collection is going to be run, and if it happens to be www.shared_host1.com, then any sessions older than 60 minutes will be trashed, including those from www.shared_host2.com. Is this a correct statement? And if so, if each shared host were to save their own session files in their own directory using session.save_path (/shared_host1/tmp, for example), would this be the ideal way to use the directives, IN COMBINATION, to get the desired effect on virtual hosted (shared) servers? I've spent some time looking for a definitive guide to the internal workings of the PHP session.gc_maxlifetime directive, particulary it's impact/effect on servers with virtual hosting (shared servers). A search across this news list as well as the php.doc turned up a couple of threads, but none that answers the question. Regards, coopster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: if/elseif/else v. switch
Good. Initially, before I sent this message, I was concerned that it was a really, really, really stupid question. But I apparently hit the mark perfectly with two reallys. Since you seem to enjoy answering them, I shall try to come up with a slew of what I hope will be really, really stupid questions, just for you. Should I send them to your e-mail directly, or share them with the whole list? After all, maybe not everyone enjoys really, really stupid questions as much as you. Just a quick note to clarify: I did ask about the difference between the two conditionals, and a difference in speed is a good example of a difference. In seriousness, if you think it's an unworthy question, why take the time to respond? Deleting the message will take far less energy. Also, I can't see the harm in asking a stupid question (or question that involves one or more reallys), so long as I get an answer. After all, it isn't as though I ask people to write scripts for me or ask questions just to avoid the hassle of looking in the manual. [Original Message] From: Aidan Lister [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/05/2004 2:04:03 AM Subject: [PHP] Re: if/elseif/else v. switch This appears to be a really, really stupid question. If they are indentical in operation, then ofcourse there will be no noticeable difference to the user. One may note that a switch statement is faster, because the condition is only evaluated once. However you did not ask about the speed difference. Dennis Seavers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is there any noticeable difference (on the part of the client) between identical conditionals, one written as a switch, the other written as an if, elseif ... else conditional? I realize that one programmer coming in behind another might prefer the gentler layout of a switch; but would there be any perceivable difference, client-side, between the options? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if/elseif/else v. switch
[Original Message] From: Aidan Lister [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/05/2004 6:19:24 AM Subject: Re: [PHP] Re: if/elseif/else v. switch Hi Rachel, You'll note I did not criticise the poster, merely his seemingly stupid question. P.S. Isn't it possible that you offended the question by criticizing it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generating graphs
On Sat, 5 Jun 2004 19:31:34 +0530, Nitin [EMAIL PROTECTED] wrote: thanks for the help, but my PHP ver is 4.0.6... Any other suggestions?? ?php $values = array(50, 80, 23, 74); $total = 227; echo 'div style=width:100px' foreach($values as $v) echo 'div style=width:' . $v / $total * 100 . 'px; background-color : red/div'; echo '/div -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prevent IE6 from blocking cookies
On Sat, 5 Jun 2004 12:55:01 -0300, Robert Winter [EMAIL PROTECTED] wrote: Do I a prevent Internet Explorer 6 from blocking cookies (session cookies, etc)? Do I have to setup something in the META HEADERS? Thanks Robert header('P3P: CP=NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'); Won't get aroung cookies just being off, but it lowers the chance of the privacy settings nuking your cookies. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prevent IE6 from blocking cookies
In IE you can turn ON or OFF accepting cookies, select Tools, Options, Security, Advanced, cookies. But the web server can't command IE to enable cookies. Do I a prevent Internet Explorer 6 from blocking cookies (session cookies, etc)? Do I have to setup something in the META HEADERS? Thanks Robert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] DB Query
Explain can help show where the slow down is. http://dev.mysql.com/doc/mysql/en/EXPLAIN.html Indexes on the c1-c5 columns should increase the speed. Explain plan? Due to the number of records, any indexes I added have significantly delayed the query. -Original Message- From: Daniel Clark [mailto:[EMAIL PROTECTED] Sent: Saturday, June 05, 2004 11:41 AM To: bskolb; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] DB Query Run an explain plan, but my first quess would be to add indexes to c1, c2, c3, c4, c5 fields. I'm trying to optimize a query that in the first example is taking too long to run. This is my existing working query: $sql = SELECT count(*) as cnt, id FROM `mYTable` WHERE c1 not in (1,16,36) and c2 not in (1,16,36) and c3 not in (1,16,36) and c4 not in (1,16,36) and c5 not in (1,16,36) GROUP BY id; Is it possible to do something like this instead (This doesn't work of course) $sql = SELECT count(*) as cnt, id FROM `myTable` WHERE (c1,c2,c3,c4,c5) not in (1,16,36) GROUP BY id; Any other suggestions are appreciated, Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Multiple URL Redirection
Hi I have the following situation: I've got a domain that is hosted at a certain host. This host allows me to create subdomains, and also to add several domains to the same account. The thing is if I add a domain like xxx.com to my yyy.com both will be directed to my index.php page. I want to know if there is a way to recognize if the user typed to the url xxx.om or yyy.com and then send it to a certain folder. I thank any word of wisdom from you guys. Rodrigo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple URL Redirection
[EMAIL PROTECTED] wrote: I've got a domain that is hosted at a certain host. This host allows me to create subdomains, and also to add several domains to the same account. The thing is if I add a domain like xxx.com to my yyy.com both will be directed to my index.php page. I want to know if there is a way to recognize if the user typed to the url xxx.om or yyy.com and then send it to a certain folder. I thank any word of wisdom from you guys. Rodrigo Try looking in the values of $_SERVER on index.php to see if there is a variable that can determine which host was requested. Depending upon how this was all set up, you should be able to get something out of there. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals - www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple URL Redirection
At 06:39 PM 6/5/2004, you wrote: Hi I have the following situation: I've got a domain that is hosted at a certain host. This host allows me to create subdomains, and also to add several domains to the same account. The thing is if I add a domain like xxx.com to my yyy.com both will be directed to my index.php page. I want to know if there is a way to recognize if the user typed to the url xxx.om or yyy.com and then send it to a certain folder. I thank any word of wisdom from you guys. Rodrigo Try: if($_SERVER[HTTP_HOST]==xxx.com){ header(Location: http://www.xxx.com/xxxdir;); }elseif($_SERVER[HTTP_HOST]==yyy.com){ header(Location: http://www.yyy.com/yyydir;); }else{ echo Huh?; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Difficult SQL (for me) - please help!
Thanks to all who helped with my earlier SQL question. It was exactly what I needed. But now I'm making it more involved. Tom and Dick are competing salesmen. The data looks like this: Tom Pitch Dick Pitch Tom Sale Dick Sale Tom Pitch I want to show a list of salesmen, sorted by rate of sales: Dick 1 sale in 2 tries, 50.0% Tom1 sale in 3 tries, 33.3% Is this possible with a single SQL statement? Many thanks, - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Difficult SQL (for me) - please help!
Brian Dunning wrote: Thanks to all who helped with my earlier SQL question. It was exactly what I needed. But now I'm making it more involved. Tom and Dick are competing salesmen. The data looks like this: Tom Pitch Dick Pitch Tom Sale Dick Sale Tom Pitch I want to show a list of salesmen, sorted by rate of sales: Dick 1 sale in 2 tries, 50.0% Tom1 sale in 3 tries, 33.3% Is this possible with a single SQL statement? Many thanks, SELECT name, SUM(IF(result='Pitch',1,0)) as Tot_Pitches, SUM(IF(result='Sale',1,0)) as Tot_Sales, COUNT(result) AS cnt FROM yourtable GROUP BY name -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php