Re: [PHP] need help with foreach
Its not very clear what you want to achieve with that code snippet. If you are pulling database rows out of your database with mysql_fetch_array(), then you do not need a foreach loop. I think you may want something like this, but without knowing your database table structure and the query you have used it is only a guess. while($row = mysql_fetch_array($result2,MYSQL_ASSOC)){ echo a href=client.php?art=.$row['pix']. border='0'{$row['jobType']}/a\n; if($row['url']!='')echo html to use with .$row['url']; } On 31/10/2006 10:09 [EMAIL PROTECTED] wrote: I want to tell the server to do 2 things when I click on the jobType link. This is the code that I have now which displays the art when I click on jobType foreach($row as $jobType) { $row = mysql_fetch_array($result2,MYSQL_ASSOC); echo a href=client.php?art=.$row['pix']. border='0'{$row['jobType']}/a\n; } I now want to, with the same click, also show the url if I have a url for that jobType in my database column called url. Thank you for any help. --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] Run script every 30 seconds
Sorry, slight adjustment, make that $t=time()-31; in the first line so that the script runs immediately. You could run the script as a daemon. man daemon. The sloppy way of running the script every 30 seconds would be to use sleep(30), but that would cause the script to run at 30 seconds + execution time. If you make a loop like this you could get around that: $t=time()+31; while(true){ if(time()$t+30){ $t=time(); YourMainScriptFunction(); } else usleep(1000); //adjust to how often you want to check } On 30/10/2006 17:29 Ahmad Al-Twaijiry wrote: Hi everyone, I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
You could run the script as a daemon. man daemon. The sloppy way of running the script every 30 seconds would be to use sleep(30), but that would cause the script to run at 30 seconds + execution time. If you make a loop like this you could get around that: $t=time()+31; while(true){ if(time()$t+30){ $t=time(); YourMainScriptFunction(); } else usleep(1000); //adjust to how often you want to check } On 30/10/2006 17:29 Ahmad Al-Twaijiry wrote: Hi everyone, I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] natsort()
natsort() places the array elements in natural order but not the keys. If you want your elements printed using print in a loop either reorganise the keys first or use foreach. The easiest method would be to use: foreach($dl as $filename){ print $filename; } If you insist on using a while loop you could use: $dl = array_merge($dl); to reorder the keys from 0 to array size-1. then use: while ($i = $array_count){print $dl[$i]; $i++;} If you use while you must increment $i to get all of the elements printed. Alternatively you could use a for loop after reordering the keys: for($i=0;$isizeof($dl);$i++){ print $dl[$i]; } On 26/10/2006 22:05 Sandy wrote: Hi php5 code $d = '/somedir/subdir'; $od = opendir($d); if ($od) { $dl = scandir($d); natsort($dl); } /code The sorted array is available through print_r(). How can I obtain a natsorted array that can be listed using : while ($i = $array_count){print $dl[$i]} Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php