Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. if today is $crntdate = "18/05/2007"; and i'm born $birth = "22/05/1988"; i'm not 19 years old
  2. try <?php $data["base:foo:bar"] = "test1"; $data["base:foo2:bar"] = "test2"; $data["base:foo2:bar2"] = "test3"; $data["base:foo:bar2"] = "test4"; foreach ($data as $pKey => $pValue){ $exp = explode(":", $pKey); $x = "\$out['"; //foreach ( $exp as $val ) { // build array //} $x .= implode("']['",$exp)."'] = '$pValue';"; eval($x); } echo '<pre>'; print_r($out); echo '</pre>'; ?>
  3. your 1st code do noi work try <?php $crntdate = "18/05/2007"; $birth = "22/05/1988"; $crntsplit = explode("/", $crntdate); $birthsplit = explode("/", $birth); $crntdatestamp = mktime(0, 0, 0, $crntsplit[1], $crntsplit[0], $crntsplit[2]); $birthstamp = mktime(0, 0, 0, $birthsplit[1], $birthsplit[0], $birthsplit[2]); $seconds = $crntdatestamp - $birthstamp; $years = floor($seconds / 31536000); echo $years . " years"; ?> try <?php function my_old($birth, $curent = '') { $curent = $curent ? $curent : date('d/m/Y'); $birth = explode('/',$birth); $curent = explode('/', $curent); $days = array(31,31,28,31,30,31,30,31,31,30,31,30,31); if (($birth[2] % 4 == 0 and $birth[2] % 100 != 0) or $birth[2] % 400 == 0) $days[2] = 29; if ($birth[0] > $curent[0]) $curent[0] += $days[--$curent[1]]; if ($birth[1] > $curent[1]) { $curent[1] += 12; $curent[2] --; } return array('year' => $curent[2] - $birth[2], 'month' => $curent[1] - $birth[1], 'day' => $curent[0] - $birth[0]); } print_r(my_old('22/05/1988')); ?>
  4. try <?php function pag($items = '4') { $n = 0; $out = ''; $keyword_file = array('apple', 'brain', 'computer', 'drain', 'elemental', 'fruit', 'green'); $keyword = 'computer'; $keyword_file = array_map('trim', $keyword_file); asort($keyword_file); $out .= 'Here STARTS'; $test = false; foreach($keyword_file as $keyword1) { if ($keyword == $keyword1) $test = true; if ($test) { $out .= "\n".'<a href="http://'.THIS_DOMAIN.'/'.str_replace(" ", "-", $keyword1).'" title="'.$keyword1.'">'.$keyword1.'</a><br />'; $n++; if ($n >= $items) break; } } $out .= "\n".'Here ENDS'; print $out; } pag(); ?>
  5. try <?php # ENTER NAME OF TABLE TO BE displayed $groups = "SELECT * FROM $dbtable ORDER BY food"; $grouped = mysql_db_query($db,$groups,$cid); //to obtain number of groups $total_records = mysql_num_rows($grouped); //$where = array(); echo "Rows: $total_records"; echo '<table>'; //$params=mysql_fetch_array($grouped) $prev_food = ''; while ($testparams=mysql_fetch_array($grouped)){ $food=$testparams['food']; $type = $testparams['food_type']; if ($food != $prev_food) { echo "<td valign=top>$food</td>\n"; //to obtain the group names $prev_food = $food; } echo '<br />', $type, "\n"; } ?>
  6. try <?php require('get_connected.php'); $title = $_POST['title']; $sql = "SELECT title, issue_number, cover_date, comic_id FROM comics WHERE title ='" . $title . "'" $result = mysql_query($sql)) or die(mysql_error()); if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo $row['title']; } } echo $row['title'] . "<br>"; ?>
  7. look nl2br() function
  8. you miss last ) in line . mysql_real_escape_string($mfm_NewImgName) . "')" // <-- this line
  9. try $sql="SHOW TABLE STATUS LIKE 'table_name'";
  10. Parse error: parse error, unexpected T_VARIABLE you miss ; inline before
  11. can we see 5 more lines before your code snippet
  12. try <?php $a1 = Array ( 'mp3' => Array ( 'song1.mp3' => 'path/to/song1.mp3', 'song2.mp3' => 'path/to/song2.mp3', 'song3.mp3' => 'path/to/song3.mp3', 'mp3/riffs' => Array ( 'riff1.mp3' => 'path/to/riff1.mp3', 'riff2.mp3' => 'path/to/riff2.mp3', 'riff3.mp3' => 'path/to/riff3.mp3' ) ), 'ogg' => Array ( 'song1.ogg' => 'path/to/song1.ogg', 'song2.ogg' => 'path/to/song2.ogg', 'song3.ogg' => 'path/to/song3.ogg', 'ogg/riffs' => Array ( 'riff1.ogg' => 'path/to/riff1.ogg', 'riff2.ogg' => 'path/to/riff2.ogg', 'riff3.ogg' => 'path/to/riff3.ogg', 'ogg/riffs/old' => array( 'riff4.ogg' => 'path/to/riff4.ogg' ) ) ) ); function reorg($a, $b='') { $out =array(); foreach ($a as $key => $value) { if (!$b){ foreach ($value as $k1 => $v1) { if (!is_array($v1)) $out[$key][$k1] = $v1; else { $tmp = reorg($v1,$k1); foreach ($tmp as $k2 => $v2) $out[$k2] = $v2; } } } else { if (!is_array($value)) $out[$b][$key] = $value; else { $tmp = reorg($value,$key); foreach ($tmp as $k2 => $v2) $out[$k2] = $v2; } } } return $out; } print_r(reorg($a1)); ?>
  13. try[codeg<script language="JavaScript" > function to_m(){ var f = document.getElementById('f').value; var m = f*0.0283168466; document.getElementById('m').value = m; } function to_f() { var m = document.getElementById('m').value; var f = m/0.0283168466; document.getElementById('f').value = f; } </script> <form method='post' action=''> <input type='text' name='CubicFeet' id='f' onkeyup='to_m()'> CubicFeet <br /> <input type='text' name='CubicMeters' id='m' onkeyup='to_f()'> CubicMeters </form>
  14. <a href="index.php">< back</a> <br /><br /> <?php // Set the database access information as constants. $DBhost = "localhost"; $DBuser = "root"; $DBpass = ""; $DBName = "bf-customer"; $table = "customer"; mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); $id = $_POST['id']; //add this line // the 'insert' that will insert the data as a new row into the table under the respective columns. mysql_query("DELETE FROM customer where id = '$id'") or die(mysql_error()); echo "<br />"; echo "Data Deleted!"; ?>
  15. $user = 200; $sql = "SELECT profile_id, COUNT( trait_id ) AS c FROM matches WHERE trait_id IN (SELECT trait_id FROM matches WHERE profile_id =$user) AND profile_id <>$user GROUP BY profile_id ORDER BY c DESC";
  16. try <?php $arrayin=Array ( 'P1' => Array('A', 'B', 'C'), 'P2' => Array('D', 'E', 'F'), 'P3' => Array('G'), 'P4' => Array('H', 'I') ); $skip = array('B','D','E'); function permut($arr, $skip = array()){ if (count($arr) == 0) return array(''); $key = array_keys($arr); $a1 = $arr[$key[0]]; unset($arr[$key[0]]); if (!is_array($a1) or count($a1) == 0) $a1 = array(''); $out=array(); $tmp = permut($arr,$skip); foreach ($a1 as $val){ if (!in_array($val,$skip)) foreach ($tmp as $val2) $out[] = $val.$val2; } return $out; } $b = permut($arrayin); print_r($b); $b = permut($arrayin,$skip); print_r($b); ?> or <?php $arrayin=Array ( 'P1' => Array('A', 'B', 'C'), 'P2' => Array('D', 'E', 'F'), 'P3' => Array('G'), 'P4' => Array('H', 'I') ); $skip = array('P1' => array('B'),'P2' => array('D','E')); function permut($arr, $skip = array()){ if (count($arr) == 0) return array(''); $key = array_keys($arr); $a1 = $arr[$key[0]]; unset($arr[$key[0]]); if (!is_array($a1) or count($a1) == 0) $a1 = array(''); $out=array(); $tmp = permut($arr,$skip); $s = array_key_exists($key[0],$skip) ? $skip[$key[0]] : array(); foreach ($a1 as $val){ if (!in_array($val,$s)) foreach ($tmp as $val2) $out[] = $val.$val2; } return $out; } $b = permut($arrayin); print_r($b); $b = permut($arrayin,$skip); print_r($b); ?>
  17. try <?php $data = array('cork' => array(400,800,405,700), 'mouse' => array(684,304,709,913)); $object = 'cork'; $option = 2; $number = 50251; $out = ceil($number/$data[$object][$option-1]); echo $out; ?>
  18. try <?php $arrayin=Array ( 'P1' => Array ( 0 => 'A', 1 => 'B', 2 => 'C' ), 'P2' => Array ( 0 => 'D', 1 => 'E', 2 => 'F', ), 'P3' => Array ( 0 => 'G' ), 'P4' => Array ( 0 => 'H', 1 => 'I' ) ); function permut($arr){ if (count($arr) == 0) return array(''); $key = array_keys($arr); $a1 = $arr[$key[0]]; unset($arr[$key[0]]); $out=array(); $tmp = permut($arr); foreach ($a1 as $val){ foreach ($tmp as $val2) $out[] = $val.$val2; } return $out; } $b = permut($arrayin); print_r($b); ?>
  19. $result = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_array($result)) { echo $row['Title']; print"<br><br>\n"; $Location = $row['Location']; // or the your name for location in db if (!isset($Location) || empty($Location)) { print "No location..."; } else { print "Location available"; } } mysql_close($con); ?>
  20. add line $Location = "row['Location']; before if and after while
  21. what is wrong? it looks OK for me
  22. use array <?php $data =array( array('name' => 'corh', 1 => 400, 2 => 800, 3 => 405, 4 => 700), array('name' => 'mouse', 1 => 684, ;2 => 304, 3 => 709, 4 => 913) ); ?>
  23. try $searchtype = ($_POST['searchtype']); $all_users = ($_POST['all_users']); if($all_useers='all_users') $x = '1'; else $x="sponsor='$searchtype'"; $query="SELECT * FROM people where ".$x; etc.
  24. try $sql = "SELECT * FROM " .$year_arr[$i]. "data WHERE ENGFAM = '$efn' AND EO IN (SELECT max(EO) FROM " .$year_arr[$i]. "data WHERE ENGFAM = '$efn' GROUP BY LEFT(EO,6)) ORDER BY Verified DESC";
  25. is EO name of your field where you store the number (DE-200, DE-200-01) ?
×
×
  • 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.