Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try <?php $a = Array('Array' => Array(Array('blue', 'red', 'white' ), Array ('navy', 'grey')),2); $b = Array('Array' => Array(Array('ferari', 'dodge', 'cadilac'), Array('jeans', 'loafers')),9); function my_combine($keys, $values) { $out = array(); if (count($keys) != count($values)) return false; $a = array_keys($keys); $b = array_keys($values); for ($i = 0; $i < count($keys); $i++){ if (is_array($keys[$a[$i]])){ if (is_array($values[$b[$i]])){ $out[$a[$i]] = my_combine($keys[$a[$i]], $values[$b[$i]]); } else return false; } else if (is_array($values[$b[$i]])) return false; $out[$keys[$a[$i]]] = $values[$b[$i]]; } return $out; } $c=my_combine($a,$b); print_r($c); ?>
  2. <?php $myArray["charley"] = "30"; $myArray["chris"] = "28"; $myArray["kate"] = "25"; $key = array_keys($myArray); for ($i = 0; $i < 3; $i++){ echo 'key ->',$key[$i],'<br />value ->',$myArray[$key[$i]],"<br />\n"; } ?>
  3. try <?php $curent_state =''; do { if ($row_StoresDb['state'] != $curent_state) { $curent_state = $row_StoresDb['state']; ?> <tr> <td height=19 align=CENTER valign=TOP><b><font face="Times New Roman"><?php echo $row_StoresDb['state']; ?></font></b></td> <td align=CENTER valign=TOP><font face="Times New Roman"> </font></td> <td align=CENTER><font face="Times New Roman"> </font></td> </tr> <?php } ?> <tr> <td height=17 align=CENTER valign=TOP><font face="Times New Roman"><?php echo $row_StoresDb['retailer']; ?></font></td> <td align=CENTER valign=TOP><font face="Times New Roman"><a href="<?php echo $row_StoresDb['url']; ?>"> <?php echo $row_StoresDb['address']; ?> </a></font></td> <td align=CENTER><font face="Times New Roman" color="#000000"><?php echo $row_StoresDb['phone']; ?></font></td> </tr> <tr> <td height=17 align=CENTER valign=TOP> </td> <td align=CENTER valign=TOP> </td> <td align=CENTER> </td> </tr> <?php } while ($row_StoresDb = @mysql_fetch_assoc($StoresDb)); ?>
  4. <?php $myArray["charley"] = "30"; $myArray["chris"] = "28"; $myArray["kate"] = "25"; $key = array_keys($myArray); for ($i = 0; $i < 3; $i++){ echo $myArray[$key[$i]],"<br />\n"; } ?>
  5. try while ($get_info = mysql_fetch_row($result)){ $field = $get_info[0]; print '<option value="'. $field. '>'.$field.'</option>'; }
  6. $wc_after = preg_match_all('/[\w\']+/s',preg_replace('/\[.+?\]/','',$post_text),$a); $wc_after = count($a[0]);
  7. change the names of your fields from field1 to field1[] etc.
  8. for($i = 0;$i <=10; $i++) { $data = $final[$i]; echo $data[2]; echo $data[3]; echo $data[4]; }
  9. it's many way to solve this 1st change function dbconnect($conn, $db) to function dbconnect(&$conn, &$db) 2nd change $result= @mysql_query($sql, $conn )or die("Could not pull products"); to $result= @mysql_query($sql)or die("Could not pull products"); 3rd change your function to return $conn
  10. <?php $a='$'; if(preg_match('/[“”;;”””?#$$%%&&+]/', $a, $b)) echo 'error'; else echo 'ok'; ?>
  11. try <?php $a = 'Server Statistics for \\testbox Statistics since 5/2/2008 4:06 PM Sessions accepted 1 Sessions timed-out 0 Sessions errored-out 0 Kilobytes sent 16 Kilobytes received 17 Mean response time (msec) 0 System errors 0 Permission violations 0 Password violations 0 Files accessed 16 Communication devices accessed 0 Print jobs spooled 0 Times buffers exhausted Big buffers 0 Request buffers 0 The command completed successfully.'; preg_match('/Kilobytes sent\s+(\d+) Kilobytes received\s+(\d+)/', $a, $b); print_r($b); ?>
  12. <?php $a = file('gin002.txt'); /* $a = 'RL RL ACCOUNTANTS WAREHOUSE 6070 MC*DONOUGH DR N*W NORC 770 326-6302V2 RL ACCOUN*TAX PROFESSIONAL 770 447-1244V2 RL ACCOUNTAX SERVICE 6000 LIVE OAK PKWY N*W NORC 678 206-0361V2'; $a = explode("\n",$a); */ foreach ($a as $row => $line){ //$data[0] = trim(substr($line, 0, 16))."<br />"; //$data[1] = trim(substr($line, 16,125))."<br />"; $data[2] = trim(substr($line,141, 55))."<br />"; $data[3] = trim(substr($line,196, 32))."<br />"; $data[4] = trim(substr($line,228, 14))."<br />"; //$data[5] = trim(substr($line,240, 2))."<br />"; if ($data[2]!= "<br />" or $data[3] != "<br />" or $data[4] != "<br />") $final[] = $data; } //$a = explode("\n",$a); print_r($final)."<br />"; ?>
  13. try to change your HTML to <input type="hidden" name='power[chat][{$row['userID']}]' value='0'> <input type='checkbox' name='power[chat][{$row['userID']}]' value='1'>
  14. try <?php $a = array(1,2,3,4); function my_permut($a){ if (count($a) == 1)return array($a, array()); $out = array(); foreach ($a as $k => $v){ unset($a[$k]); $b = my_permut($a); $out = array_merge(my_merge($v, $b), $out); $out = array_merge($out, $b); break; } return $out; } function my_merge($a, $b){ if (count($b) == 0) return array($a); foreach ($b as $k => $v){ array_unshift($v, $a); $b[$k] = $v; } return $b; } $b = my_permut($a); print_r($b); ?>
  15. try <?php $a = 'RL ACCOUNTANTS WAREHOUSE 6070 MC*DONOUGH DR N*W NORC 770 326-6302V2 RL ACCOUN*TAX PROFESSIONAL 770 447-1244V2 RL ACCOUNTAX SERVICE 6000 LIVE OAK PKWY N*W NORC 678 206-0361V2'; $a = explode("\n",$a); $final = array(); foreach ($a as $row => $line){ $data[0] = trim(substr($line, 0, 16)); $data[1] = trim(substr($line, 16,125)); $data[2] = trim(substr($line,141, 55)); $data[3] = trim(substr($line,196, 32)); $data[4] = trim(substr($line,228, 12)); $data[5] = trim(substr($line,240, 2)); $final[] = $data; } print_r($final); ?>
  16. try <?php include("code.php"); $conn = mysql_connect("localhost","fierm","13183"); if(!$conn) { echo "failed"; } else { mysql_select_db("fierm"); echo "Choose a Course to Register"; $result=mysql_query("select CourseID,CourseName,SeatLimit from Course"); $result1=mysql_query("Select CourseID,StudentID from Rcourse where StudentID='{$_SESSION['user']}'"); // put all studen's courses in array while ($r = mysql_fetch_array($result1)) $Courses[] = $r['CourseID']; echo "<table border = \"1\">"; echo "<tr><td>CourseID</td><td>CourseName</td><td>Seats</td><td>Register</tr>"; while($row=mysql_fetch_array($result)) { $CourseID = $row['CourseID']; $CourseName= $row['CourseName']; $SeatLimit= $row['SeatLimit']; /* $r=mysql_fetch_array($result1)) $Course = $r['CourseID']; foreach($row as $value){ if($CourseID ==$Course){ */ if (in_array($CourseID, $Courses)) $value = "Already Took Course"; // check is course in student courses array elseif($SeatLimit == 0) $value = "Full"; else $value="<a href=\"checkRegCourses.php?ci=$row[0]&cn=$row[1]\">Register</a>"; //$strUrl = "<a href=\"checkRegCourses.php?ci=$row[0]&cn=$row[1]\">Register</a>"; echo "<tr><td>$CourseID</td><td>$CourseName</td><td>$SeatLimit</td><td>$value</td></tr>\n"; } echo "</table>"; } ?>
  17. use $num = mysql_result($result,0);
  18. //Set the MySQL query if ($search == NULL or $search == '%'){ } else { // generate WHERE part foreach ($keywords as $word){ $where[] = "CourseID LIKE '%$word%' OR CourseTitle LIKE '%$word%' OR CourseAims LIKE '%$word%'"; } if (count($where)) $where = 'WHERE ('.implode(') OR (', $where).')'; $query = "SELECT * FROM CourseTbl " .$where." ORDER BY CourseTitle"; }
  19. preg_match('/<TABLE WIDTH=400.*?<\/TABLE>/is', $page, $b); print_r($b[0]);
  20. no $events = "SELECT events FROM user WHERE username ='$username' AND read=0";
  21. try <?php $where = "make_id = 'Ford' AND model_id = 'Focus' AND year ='2005'"; preg_match_all('/([^ ]*)[ ]*=[ ]*([^ ]*)/', $where, $a); foreach ($a[0] as $k => $v){ echo ucfirst(trim($a[1][$k],'_id')),': '. trim($a[2][$k], "'"), "<br />\n"; } ?>
  22. try <?php function get_my_level($e){ $levels = array(0,10000,20000,30000,40000); $max_level = count($levels) - 1; $level = $max_level; while ($levels[$level] > $e) $level--; if ($level == $max_level){ return array('level' => $level, 'next_level' => 'no next', 'precent' => 0); } $next_level = $levels[$level + 1]; $precent = ($e - $levels[$level]) / ($levels[$level + 1] - $levels[$level]) * 100; return array('level' => $level, 'next_level' => $next_level, 'precent' => $precent); } $level = get_my_level(919999); print_r($level); ?>
  23. SELECT * FROM tablename WHERE id IN(1,2,3,4) ORDER BY FIELD(id,1,4,3,2)
  24. ... $page = file_get_contents("http://ty_marian:djs1001@tarka.matilda.net.au/custdata/time-block-list.php3?login_id=9584"); preg_match('/<table.*?<\/table>/is', $page, $b); print $b[0]; ?>
×
×
  • 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.