Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. look <?php $ord = range('a', 'z'); $time = 3; for ($i= 1; $i < $time; $i++) array_push($ord, array_shift($ord)); $ord = implode("','",$ord); $sql = "SELECT .... ORDER BY FIELD(LCASE(LEFT(`field_name`, 1)),'$ord')"; ?>
  2. set $i = 1 before while loop
  3. change else { mysql_free_result($SqlQuestionSelected); $SqlQuestionSelected = ""; getMcqQuestion(); } to else { mysql_free_result($SqlQuestionSelected); $SqlQuestionSelected = ""; return getMcqQuestion(); }
  4. try <?php $a = array('a','b','c','d'); $b = array('a','b','c','d'); $tmp = range(1, 4); shuffle($tmp); array_multisort($tmp, $a, $b); print_r($a); print_r($b); ?>
  5. look <?php $test ='*vocab sasa end*'; echo $b =preg_replace('|\*vocab *(.*?) *end\*|',"<a href='searchdo.php?vocab=$1'>$1</a>",$test); ?>
  6. try <?php require("includes/db.php"); $sql = "select * from users order by `s_phish` desc"; $result = mysql_query($sql, $link) or die(mysql_error()); ?> <center> <table cellpadding="0" width="50%" cellspacing="0"> <tr> <td> Rank </td> <td> Name </td> <td> Phishes </td> </tr> <?php $rank = 0; $score = 'imposible'; while ($row = mysql_fetch_array($result) AND $rank < 20) { $rank++; // adds 1 if($row['s_phish'] == $score){ $score = row['s_phish']; $rank1 = $rank; } echo "<tr><td>"; echo $rank1; echo "</td><td>"; echo " <a href='profile.php?id="; echo $row['id']; echo "'>"; echo $row['name']; echo "</a> "; echo "</td><td>"; echo $row['s_phish']; // put HTML break to end line echo "</td></tr>"; // echo "<br />"; } ?> </table> </center>
  7. if 2 users have same score do they have same rank or not if not who has beter rank
  8. change line if(empty($page)){$page = 1;} to $page = $_GET['page'] ? (int) $_GET['page'] : 1;
  9. line while (($cat_row = mysql_fetch_assoc(mysql_query($sql))) cause infinity loop in each loop you query database again and again solution change to $rez=mysql_query($sql); while (($cat_row = mysql_fetch_assoc($rez)) same in line while ($n_cat_prod_row = mysql_fetch_assoc(mysql_query($n_sql)))[(code]
  10. change lines if (empty($s)) { $s=0; to $s = $_GET['s'] ?(int) $_GET['s'] : 0;
  11. try <?php if(isset($_POST['submit2'])) { $price = $_POST["grandtotal"]; if(isset($_SESSION["email"])) { $frmemail = $_SESSION["email"]; } else { // you can't use echo before header() echo "Error. Please login again."; header("Location:home-pub.php?logout"); } $now = date("d/m/Y"); $next = date('d/m/y', strtotime("+1 year")); if($price == 0 || strlen($price) == 0) { echo "Invalid price"; } else { $county = array(); //$county = array(150); $m = 0; for($i=0;$i<120;$i++) { $checkbx = isset($_POST['countybox' . $i]); if (isset($_POST['countybox' . $i])) { $county[$m] = $_POST['countybox' . $i]; $m++; } } $now = date("d/m/Y"); $next = date('d/m/Y', strtotime("+1 year")); print_r($county); //for debuging } } ?>
  12. can we see SQL for select data from db
  13. in your form you have line <input type="checkbox" name="countybox1" value="Bedfordshire" onClick="countyCount(this)"> Bedfordshire<br> what this function do?
  14. can we see countyCount() function
  15. try <?php function my_replace($search, $replace, $array){ if (is_array($search) and is_array($replace) and count($search) != count($replace)) return false; if (is_array($search)) foreach ($search as $k => $v) $search[$k] = 's:'.strlen($v).':"'.$v.'";'; else $search = 's:'.strlen($search).':"'.$search.'";'; if (is_array($replace)) foreach ($replace as $k => $v) $replace[$k] = 's:'.strlen($v).':"'.$v.'";'; else $replace = 's:'.strlen($replace).':"'.$replace.'";'; $array = serialize($array); $array = str_replace($search, $replace, $array); return unserialize($array); } $test = Array ( Array(array('columna' => 'placeholder', 'columnb' => 'somename1', 'columnc' => 'placeholder'),'columnx' => 'placeholder'), Array('columna' => 'valuegoeshere', 'columnb' => 'somename2', 'columnc' => 'anothervaluegoeshere') ); $test = my_replace(array('somename1', 'somename2'), array('sasa', 'john'), $test); print_r($test); ?>
  16. try <?php $test = "help{*}=?"; echo urlencode($test); ?>
  17. preg_match('/<td valign="top" class="maintab_back">(.*)Staff List<\/a>/s',$data,$newdata); echo $newdata[1];
  18. select comp_name, COUNT(id) as num, CAST(GROUP_CONCAT(id) AS CHAR) as ids FROM table_name GROUP BY name
  19. try <?php function gcd($a,$b){ while ($c = $a % $b){ $a = $b; $b = $c; } return $b; } echo gcd(4,6); ?>
  20. try <?php $sidAll = $_POST['sidAll']; $sid = $_POST['sid']; //$sessionCount = $_POST['sessionCount']; //count the number of sessions selected //$sessionCountSelected = count($sid); //if the number selected and number defined differ, then update the session enrollment table //if ($sessionCount != $sessionCountSelected) { //cycle through ALL the sessions defined and determine which ones were DESELECTED //$count = 0; foreach ($sidAll as $temp) { if (in_array($temp,$sid)) { print "<br />UPDATE senroll SET status = 'e' WHERE sid = '$temp' <br>"; } else { print "<br />UPDATE senroll SET status = 'u' WHERE sid = '$temp' <br>"; } // $count++; // } } ?>
  21. select comp_name, COUNT(id) as num, GROUP_CONCAT(id) as ids FROM table_name GROUP BY name
  22. try SELECT t.name, t.xp-y.xp as change FROM table_name as y, table_name as t WHERE y.`date`=yesterday_date and t.`date`=today_date and y.name=t.name ORDER BY change DESC
  23. if(count(array_intersect($array_1,$array_2)))
  24. or <?php function my_r($a, $d){ $l = ceil(strlen($a)/3) * 3; $a= str_pad($a, $l, '0', STR_PAD_LEFT); for ($i=0; $i<$l; $i+=3) $ar[] = substr($a,$i,3); $r = 0; foreach ($ar as $part) $r = ($r *1000 + $part) % $d; return $r; } $test = '2655429305'; echo my_r($test, 36); ?>
  25. or <?php $test = 'as X X 8 sdX(dX asXd) as X (ohXXX) X X'; for ($i = 0, $count = 0; $i < strlen($test); $i++){ switch ($test[$i]){ case '(' : $count++; break; case ')' : $count--; break; case 'X' : if($count) $test[$i] = '_'; break; } } echo $test; ?>
×
×
  • 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.