Hello,
Request some help in PHP programming.... How to code in the following situation....
Req.: Have an array of Name & surname & Client_code. Need to print a list without LISTING PEOPLE WITH SIMILAR "NAME & "SURNAME" IN THE ARRAY more than once.
Eg. 1: name1 : surname1 : client1 2: name2 : surname2 : client2 3: name3 : surname3 : client3 4: name1 : surname1 : client4 5: name5 : surname5 : client5 6: name2 : surname3 : client6
In the above example, record 1 & 4 are same guys. And I have to list them only once.
What I have done so far is....
for ($i = 0; $i < 6; $i++) { printf ($name[$i] . $surname[$i] . " manages " . $client[$i] \n"); } // end $i
But this prints same people multiple times...
Pls help. Pls do not suggest changing variables etc etc... Thx Poonam.
________________________________________________________________________ Want to sell your car? advertise on Yahoo Autos Classifieds. It's Free!! visit http://in.autos.yahoo.com
<? //store as multidimesion arry element for simlipicity $data[0]=array ( "1","name1","surname1","client1"); $data[1]=array ( "2","name2 ","surname2 ","client2"); $data[2]=array ( "3","name3 ","surname3 ","client3"); $data[3]=array ( "4","name1 ","surname1 ","client4"); $data[4]=array ( "5","name5 ","surname5 ","client5"); $data[5]=array ( "6","name2 ","surname3 ","client6"); sort($data); $total=count($data); $prev=""; for($i=0;$i<$total;$i++) { $current=$data[$i][1].":".$data[$i][2]; //echo "\n $prev $current"; if($prev!=$curent) { echo " ".$data[$i][0]."=>".$data[$i][1]." ".$data[$i][2] ." Manages ".$data[$i][3].".\n "; } $prev=$current; }
?> On Thursday 08 August 2002 05:27 pm, Poonam P wrote:
Req.: Have an array of Name & surname & Client_code. Need to print a list without LISTING PEOPLE WITH SIMILAR "NAME & "SURNAME" IN THE ARRAY more than once.
Eg. 1: name1 : surname1 : client1 2: name2 : surname2 : client2 3: name3 : surname3 : client3 4: name1 : surname1 : client4 5: name5 : surname5 : client5 6: name2 : surname3 : client6
In the above example, record 1 & 4 are same guys. And I have to list them only once.
What I have done so far is....
for ($i = 0; $i < 6; $i++) { printf ($name[$i] . $surname[$i] . " manages " . $client[$i] \n"); } // end $i
But this prints same people multiple times...
Pls help. Pls do not suggest changing variables etc etc... Thx Poonam.
Want to sell your car? advertise on Yahoo Autos Classifieds. It's Free!! visit http://in.autos.yahoo.com _______________________________________________ http://mm.ilug-bom.org.in/mailman/listinfo/linuxers
Thx this code was of great help. Another small query..... How to execute shell commands which otherwise require root permissions, from a browser using PHP form. Eg. "mysqld stop", "Reboot" etc.
Thx. Poonam
--- Sachin sachin@mediaibc.com wrote: > <?
//store as multidimesion arry element for simlipicity $data[0]=array ( "1","name1","surname1","client1"); $data[1]=array ( "2","name2 ","surname2 ","client2");
________________________________________________________________________ Want to sell your car? advertise on Yahoo Autos Classifieds. It's Free!! visit http://in.autos.yahoo.com
Sorry , i do not think there is way of executing root level commands using Apache+PHP combination as apache/httpd is separte user ^^^^^^^^^^^^^^^^^^^^^^^^ but u can if u start the perl script as webserver as "Webmin" program does and then enjoy
On Tuesday 13 August 2002 09:19 pm, Poonam P wrote:
: How to execute shell commands which otherwise require : root permissions, from a browser using PHP form. : Eg. "mysqld stop", "Reboot" etc.
On Tue, 13 Aug 2002, Poonam P wrote:
How to execute shell commands which otherwise require root permissions, from a browser using PHP form. Eg. "mysqld stop",
the short answer is don't - ever. Giving a web script the ability to execute anything as root will open a huge security hole in your system. The safe way would be to get the web script to mail an administrator requesting appropriate action.
For other users, and if you're sure that your script is secure (there's many things to consider), you can use a setuid wrapper.