vidyashankara Posted June 9, 2006 Share Posted June 9, 2006 [code] if ($het[0] == $het[0]) { $command = "c at $file |grep ^HETATM |grep ' $het[0] ' > ${id}_$het[0].pdb";s ystem($command, $output);$new file = "${id}_$het[0].pdb";$input = f ile($newfile); // read file into an array$fp = f open($newfile,'w'); // open output file for writeforeach($input as $line) {if ($line[17]=='H') { if ($line[18]=='O') { if ($line[19]=='H') { $line[72] = 'W'; //the first character of the string is at position 0 $line[73] = 'A'; $line[74] = 'T'; $line[75] = '1'; $line[17] = 'T'; $line[18] = 'I'; $line[19] = 'P'; $line[20] = '3'; $line[13] = 'O'; $line[14] = 'H'; $line[15] = '2'; $line[0] = 'A'; $line[1] = 'T'; $line[2] = 'O'; $line[3] = 'M'; $line[4] = ' '; $line[5] = ' ';}}}else { $line[0] = 'A'; $line[1] = 'T'; $line[2] = 'O'; $line[3] = 'M'; $line[4] = ' '; $line[5] = ' '; $line[72] = 'H'; $line[73] = 'E'; $line[74] = 'T'; $line[75] = '1';}f write($fp,$line);}f close($fp);echo "${id}_$het[0].pdb<br>";}[/code]The problem is how do i make ($het[0] == $het[0]) dynamic? $het[0] is the result of a checkbutton from the prev. page.Lets say het[0] = AC9het[1]=HOHI want the script to perform certain instructions dynamically.System commands and file options without spaces... ofcourse. Quote Link to comment https://forums.phpfreaks.com/topic/11610-improvements/ Share on other sites More sharing options...
Fyorl Posted June 9, 2006 Share Posted June 9, 2006 checkboxes aren't sent as data unless they're checked. So all the checkbox data you receive will contain the values of the checkboxes that were ticked but will not contain any entries for checkboxes that were ignored Quote Link to comment https://forums.phpfreaks.com/topic/11610-improvements/#findComment-43823 Share on other sites More sharing options...
vidyashankara Posted June 9, 2006 Author Share Posted June 9, 2006 [!--quoteo(post=382039:date=Jun 9 2006, 04:26 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 04:26 PM) [snapback]382039[/snapback][/div][div class=\'quotemain\'][!--quotec--]checkboxes aren't sent as data unless they're checked. So all the checkbox data you receive will contain the values of the checkboxes that were ticked but will not contain any entries for checkboxes that were ignored[/quote]I know that. Lets say there are 10 checkboxes, all clicked. How do i make the script perfrom instructions for all the boxes.. writing the code for just one? The script should use the Value of the checkboxes to make changes. Quote Link to comment https://forums.phpfreaks.com/topic/11610-improvements/#findComment-43827 Share on other sites More sharing options...
Fyorl Posted June 9, 2006 Share Posted June 9, 2006 [code]$boxes = $_REQUEST['check'];for($i = 0; $i < count($boxes); $i++){// Do whatever to $boxes[$i]}// You could use this if you didn't need to edit them using $iforeach($boxes as $key => $val){// Code}// Or if you don't need the key at all and just the value:foreach($boxes as $box){// Code}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11610-improvements/#findComment-43834 Share on other sites More sharing options...
vidyashankara Posted June 9, 2006 Author Share Posted June 9, 2006 [!--quoteo(post=382050:date=Jun 9 2006, 04:46 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 04:46 PM) [snapback]382050[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]$boxes = $_REQUEST['check'];for($i = 0; $i < count($boxes); $i++){// Do whatever to $boxes[$i]}// You could use this if you didn't need to edit them using $iforeach($boxes as $key => $val){// Code}// Or if you don't need the key at all and just the value:foreach($boxes as $box){// Code}[/code][/quote]when i do this, How do i define individual box? for example, I need to name the file as atom_(check box value).pdb.How do i define the check box value for different boxes?If i define it a atom_$boxes.pdbit comes up as atom_Array.pdb Quote Link to comment https://forums.phpfreaks.com/topic/11610-improvements/#findComment-43839 Share on other sites More sharing options...
Fyorl Posted June 9, 2006 Share Posted June 9, 2006 [code]foreach($boxes as $box){$fname = 'atom_' . $box . '.pdb';}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11610-improvements/#findComment-43841 Share on other sites More sharing options...
vidyashankara Posted June 9, 2006 Author Share Posted June 9, 2006 [!--quoteo(post=382057:date=Jun 9 2006, 04:55 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 04:55 PM) [snapback]382057[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]foreach($boxes as $box){$fname = 'atom_' . $box . '.pdb';}[/code][/quote]Perfect! works like a charm!!!Thanks a lot :) Quote Link to comment https://forums.phpfreaks.com/topic/11610-improvements/#findComment-43845 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.