Jump to content

phpretard

Members
  • Posts

    821
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling
  • Location
    Florida

phpretard's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. If they need help there are some great forums out there
  2. Well that solved it. but i don't see a "solved" option THANK YOU!
  3. I need to echo the "reward.id" $sql = "select reward.id, reward.location, reward.industry, reward.title, reward.stamp, industry.id, industry.label, industry.location FROM reward LEFT JOIN industry ON industry.id = reward.industry where (industry.label = '".$_GET['ind']."' and industry.location = '".$_GET['loc']."')"; $result = mysql_query($sql) or die(mysql_error()); while($info = mysql_fetch_assoc($result)){ echo $info['HOW TO I PRINT reward.id']; }free($result ); Any thoughts?
  4. To be able to edit a particular page one of the comma separated numbers stored in your row must match the page number you may be trying to edit. The check boxes are for the primary site admin to populate / edit / update the different users rows. I could store the numbers in sessions but the session values still have to be populated somehow. [attachment deleted by admin]
  5. Unfortunately I usually do make it too difficult. I have to compare arrays because with the checkboxes as displayed as they are how else will I know which ones to take away from permissions or add? Can you send me refer me to a site regarding relational DB's. Here is the hacked up code that makes it work properly (for now). if(isset($_POST['save'])){ $existforthis = $_POST['existforthis']; $existforthis_array = explode(",", $existforthis); $impnewpages = $_POST['page']; // This is an array $expexisting = explode(",", $_POST['existing']); $permissionsremoved = array(); foreach ($expexisting as $EXPSR){ if (!in_array($EXPSR, $existforthis_array)) { $permissionsremoved[] = $EXPSR; } } if(empty($_POST['page'])){ // do nothing }else{ $permissionskept = array(); foreach ($expexisting as $EXPSK){ if (in_array($EXPSK, $impnewpages)) { $permissionskept[] = $EXPSK; } } } if(empty($_POST['page'])){ $combinedPs = $permissionsremoved; }else{ $combinedPs = array_merge($permissionsremoved, $impnewpages); } connect(); $newaccess = implode(",",$combinedPs); $sql = "update access set pid='$newaccess' where pw = '".$_POST['access']."'"; $update = mysql_unbuffered_query($sql) or die(mysql_error()); }// close if submitted
  6. So it works to a point. I cant figure which value(s) to use when updating...when. Here is my elaboration: I am basically updating the same row for one user (will be multiple eventually). This user will have access to certain pages where in this case the pages are numbered. The numbers are stored (comma separated) in a mysql text field. I call the data base for the numbers and explode them into check boxes with the value (of the check box) being the page number. Then it is determined whether or not the box should be checked or not checked. This code is working assuming there are comma separated numbers in the aforementioned text field. Updating the text field is where the problem starts. I would like to simply delete and update BUT because each page display a different range of numbers / check boxes this proposes the problem. I have gotten the code far enough along so that I can actually update the field however storing the information on the page and comparing it on submission is difficult I read the code and understand it about 85% could you maybe elaborate? if(empty($_POST['page'])){$array1 = array();}else{$array1 = $_POST['page'];} $array2 = $_POST['page_array']; $array3 = explode(",", $_POST['existing']); foreach($array1 as $v) { if(in_array($v, $array2)) { $findIt = array_search($v, $array2); unset($array2[$findIt]); } if(in_array($v, $array3)) { $findIt = array_search($v, $array3); unset($array3[$findIt]); }else{ $array3[] = $v; } } if(empty($array3)){/*do nothing to avoid implode errors*/}else{$newaccess = implode(",",$array1);} connect(); $sql = "update access set pid='$newaccess' where pw = '".$_POST['access']."'"; $update = mysql_unbuffered_query($sql) or die(mysql_error());
  7. Why do you make it look so easy??? Thank you!
  8. Yes and so far: if(empty($_POST['page'])){ // if no checkboxes are submitted $array1 = array(); $array3 = array(); $newaccess = ""; }else{ // begin problem $array1 = $_POST['page']; //OK $array2 = $_POST['page_array']; //OK $array3 = explode(",", $_POST['existing']); //OK $array4 = array_diff($array2,$array1); //HMM $newaccess = implode(",",$array4); // AH SH@@#$# } So ... if $array4 has a value then I need to add or delete it from $array3
  9. What I need is to: - take the information from array 1 - remove it from array 2 - then ADD it OR take from array 3 (this of course depends on array 1) I also have to keep in mind that array 1 could be empty thus needing to empty array 2 and IF the information is in array 3 then remove it array 3 is the main array that I will update the database row which will in turn display the correct check boxes checked or not Thank you for reading, I hope you can help me. Array //#1 this is the submitted information ( [0] => 103100000 [1] => 103200000 [2] => 103400000 [3] => 103500000 [4] => 103700000 ) Array //#2 all possible choices ( [0] => 103100000 [1] => 103200000 [2] => 103300000 [3] => 103400000 [4] => 103500000 [5] => 103600000 [6] => 103700000 ) Array //#3 currently stored in database / marks the check boxes "checked" ( [0] => 103100000 [1] => 103200000 [2] => 103300000 [3] => 103400000 [4] => 103500000 [5] => 103600000 [6] => 103700000 ) [attachment deleted by admin]
  10. This worked: $infosplit=explode("\n", $information); $array=array(); for($i=0; $i<count($infosplit); $i++) { $infosplit[$i]=trim($infosplit[$i]); if(!empty($infosplit[$i])) { $temp=explode("-", $infosplit[$i]); $temp_array=array(0=>$temp[0],1=>null,2=>null,3=>null,4=>$temp[(count($temp)-1)]); for($a=1; $a<(count($temp)-1); $a++) { $temp_array[$a]=$temp[$a]; } $array[]=$temp_array; } } print_r($array); ?>
  11. I will try that for sure... Will that be good enough to insert into? inset into table (0,1) values([0], [1], ect...) I need that in some find of foreach loop I only have a page of this...how can I grab these separately? 105-Athletics <<-- separate and explode 105-1-Eagle Sports <<-- separate and explode 105-2-Programs <<-- separate and explode 105-2-1-Boys <<-- separate and explode 105-2-1-1-Football <<-- separate and explode 105-2-1-2-Cross Country <<-- separate and explode 105-2-1-3-Golf <<-- separate and explode and so on... I am ultimately trying to echo this (without the $_GET['pg']): <li><a class="active" href="athletics.php#nfc">Athletics</a> <ul class="sub_menu"> <li><a href="page.php?pg=55#nfc">Eagle Sports</a></li> <li><a href="page.php?pg=56#nfc">Programs</a> <ul class="sub_menu"> <li><a href="page.php?pg=57#nfc">Boys</a> <ul class="sub_menu"> <li><a href="page.php?pg=58#nfc">Football</a></li> <li><a href="page.php?pg=59#nfc">Cross Country</a></li> <li><a href="page.php?pg=60#nfc">Golf</a></li> <li><a href="page.php?pg=61#nfc">Basketball</a></li> <li><a href="page.php?pg=62#nfc">Baseball</a></li> <li><a href="page.php?pg=63#nfc">Track</a></li> <li><a href="page.php?pg=64#nfc">Tennis</a></li> </ul> </li> <li><a href="page.php?pg=65#nfc">Girls</a> <ul class="sub_menu"> <li><a href="page.php?pg=66#nfc">Volleyball</a></li> <li><a href="page.php?pg=67#nfc">Golf</a></li> <li><a href="page.php?pg=68#nfc">Cheerleading</a></li> <li><a href="page.php?pg=69#nfc">Basketball</a></li> <li><a href="page.php?pg=70#nfc">Softball</a></li> <li><a href="page.php?pg=71#nfc">Track</a></li> <li><a href="page.php?pg=72#nfc">Tennis</a></li> </ul> </li> </ul> </li> <li><a href="page.php?pg=73#nfc">Coaches</a></li> <li><a href="page.php?pg=74#nfc">FHSAA</a></li> <li><a href="page.php?pg=75#nfc">Game Directions</a></li> </ul> </li>
  12. I am trying to separate this information by the "-" symbol so that I can insert it. This output would be ideal. Any help today? 105-2-2-3-Cheerleading $value[0] should = 105 $value[1] should= 2 $value[2] should= 2 $value[3] should= 3 $value[4] should= Cheerleading I have tried many approaches and come up with notta 105-Athletics 105-1-Eagle Sports 105-2-Programs 105-2-1-Boys 105-2-1-1-Football 105-2-1-2-Cross Country 105-2-1-3-Golf 105-2-1-4-Basketball 105-2-1-5-Baseball 105-2-1-6-Track 105-2-1-7-Tennis 105-2-2-Girls 105-2-2-1-Volleyball 105-2-2-2-Golf 105-2-2-3-Cheerleading 105-2-2-4-Basketball 105-2-2-5-Softball 105-2-2-6-Track 105-2-2-7-Tennis 105-3-Coaches 105-4-FHSAA 105-5-Game Directions Thank you for looking.
  13. <?php $year = date('Y'); if ($handle = opendir("results/$year/Boys")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<li><a href=\"javascript:void(0)\">$file</a> <ul> "; if ($handle2 = opendir("results/$year/Boys/$file")) { while (false !== ($file2 = readdir($handle2))) { if ($file2 != "." && $file2 != "..") { echo "<li><a href=\"javascript:void(0)\">$file2</a>"; } } } echo "</ul></li>"; } }closedir($handle);closedir($handle2); } ?>
  14. I am using 2 because I first need to get the set of folders to build the first menu then go into the folder and display the files as the sub menu. Does the code below clarify the question? <?php if ($handle = opendir("results/$year/Girls")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<li><a target=\"_blank\" href=\"javascript:void(0)\">$file</a> <ul> <li><a href=\"#\">NEED FILE 1 FROM FOLDER $file</a></li> <li><a href=\"#\">NEED FILE 2 FROM FOLDER $file</a></li> <li><a href=\"#\">NEED FILE 3 FROM FOLDER $file</a></li> <li><a href=\"#\">NEED FILE 4 FROM FOLDER $file</a></li> </ul> </li>"; } }closedir($handle); } ?>
  15. I almost have it but can't figure why the code below only shows one file per folder. I think it is showing the last file. I need $ul somehow looping to show all the files in $file. <?php $year = date('Y'); if ($handle = opendir("results/$year/Boys")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if ($handle2 = opendir("results/$year/Boys/$file")) { while (false !== ($file2 = readdir($handle2))) { if ($file2 != "." && $file2 != "..") { $ul = "<li><a href=\"#\">$file2</a></li>"; $li = "<li><a target=\"_blank\" href=\"javascript:void(0)\">$file</a> <ul> $ul </ul> </li>"; } // close if file2 }echo $li; } } } }closedir($handle);closedir($handle2); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.