Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try SELECT * FROM `table` ORDER BY (SELECT COUNT(`id`) FROM `table` a WHERE a.threadid=table.threadid) DESC
  2. try <?php function no_of_times ($srch,$start,$end) { $start =strtotime($start); $nstart = strtotime(date('Y-m-d ',$start ).$srch); $out = ($start <= $nstart) ? 1 : 0; $out += floor( (strtotime($end) - $nstart) / 86400); return $out; } $srch ='22:00:00'; $start = '2/04/07 22:00:00'; $end = '2/05/07 22:00:00'; echo no_of_times($srch, $start, $end); ?>
  3. you use same variable name ($result) in both while loop try to make names diferent ($result1 and $result2)
  4. no. the error is thet betwen this two date is 2004-02-29. it cause wrong output
  5. 3 * 365 = 1095 and 4* 365 = 1460 how years is 3?
  6. i try Orio's way <?php function calc_age($date) { $seconds = time() - strtotime($date); $year = 60*60*24*365.25; return floor($seconds / $year); } echo date('Y-m-d'), "\n"; //output 2007-02-04 echo calc_age('2004-02-05'), "\n"; // output 3 echo calc_age('2005-02-05'); // output 1 ?> Is it OK?
  7. I try jesirose's script function birthdateToAge($birthdate){ $age = array(); $now = time(); $age['seconds'] = $now-$birthdate; $age['minutes'] = floor($age['seconds']/60); $age['hours'] = floor($age['minutes']/60); $age['days'] = floor($age['hours']/24); $age['years'] = floor($age['days']/365); return $age; } $age = birthdateToAge(strtotime("March 20, 1980")); print $age['years']; it output date born: 2003-02-05<br /> today: 2007-02-04<br /> old: 4 Is it OK?
  8. try <?php echo date("D M j G:i:s T Y",strtotime($row_Recordset4['date_posted']));?>
  9. number 071230105050 == 71230105050 if you want 0 in front try $a=071230105050; echo $a,"<br />\n"; $b = sprintf('%012s',$a); echo $b; or use unix timestamp $date = '07-12-30 10:50:50'; echo $x = strtotime($date),"<br />\n"; //date to int (Unix timestamp - number of sec from 1970-1-1) $date1 = date('y-m-d h:i:s',$x); // int to date echo $date1;
  10. try <?php $link = mysql_connect("**********", "*******", "*******") or die(mysql_error()); mysql_select_db("******") or die(mysql_error()); $x = 0; mysql_query("CREATE TABLE temp( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), username VARCHAR(30), warning INT)") or die(mysql_error()); while ($x <= 101){ $y = 0; while ($y <= 101){ $afs2 = 'afs'.$x.$y; mysql_query("ALTER TABLE temp ADD $afs2 VARCHAR(30) NULL DEFAULT NULL") or die(mysql_error()); $y++; } $x++; } echo 'Table Updated!'; ?> remove ' from query btw This code will stop when $x=11 and $y=1 because afs111 is duplicate ($x=1 and $y=11)
  11. change line $query2=mysql_query("select DISTINCT Custom2 from lampworld ORDER by Custom1"); to $query2=mysql_query("select DISTINCT Custom2 AS name from lampworld WHERE Custom1='$name'");
  12. if you have line mysql_fetch_assoc($Recordset1); before for loop temowe it
  13. can you use include? try[code]<?php $test = @include_once('/config.php'); if ($test) echo 'yes'; else echo 'no'; ?>[/code]
  14. try[code]<?php function in_day($a){ $monts=array(0,31,28,31,30,31,30,31,31,30,31,30,31); $a = explode('-',$a); if (($a[0] % 400 == 0) or ($a[0] % 4 == 0 and $a[0] % 100 != 0))  $monts[2] = 29; $y = $a[0] -1; $out = $y *365 + (int) ($y / 4) - (int) ($y / 100) + (int) ($y / 400); for ($i=0;$i<$a[1];$i++) $out += $monts[$i]; $out += $a[2] - 1; return $out; } $date1='2045-12-31'; $date2='2047-12-31'; echo in_day($date2) - in_day($date1); ?>[/code]
  15. try[code]foreach($arr_am as $ai => $aa) { // foreach($arr_id as $ai) // { $x = 0; while($aa > $x) { echo $arr_id[$ai]; $x++; } // } } [/code]
  16. [code]<?php $Sigs=array('weekend.jpeg','url for first picture','2ndpicture','3rd_picture',etc); $times = array(0,5,9,14,19,24); $time = date('H'); $day = date('D'); $w_days = array('Sun','Sat'); if (in_array($day,$w_days)) $i=0; else { $i = 0; while ($time >= $times[$i]) $i++; } echo '<img src="',$Sigs[$i],'" >'; ?>[code][/code][/code]
  17. try[code]<?php $times = array(0,5,9,14,19,24); $time = date('H'); $day = date('D'); $w_days = array('Sun','Sat'); if (in_array($day,$w_days)) echo 'Pisture for weekends'; else { $i = 0; while ($time > $times[$i]) $i++; echo 'Picture no ',$i; } ?>[/code]
  18. if you script redirect to login_false.php $rec_num is zero I think that in your data table columns username and userid is not same You compare column userid with $username. Is it OK?
  19. change print $str.' = '.eval($str.';').'<br />'; to print $str.' = '; eval('print '.$str.';'); print '<br />';
  20. try[code]$name=explode("<br>", $row['resourcesneeded']); $amountIn = count($name); for($x = 0; $x < $amountIn; $x++){   print "$name[$x]<p>";   $out = explode(' ',$name[$x],2);   print 'number is ',$out[0],' and word is ',$out[1]; }[/code] for 5 Fibre Glass it output 5 Fibre Add 2 in explode function
  21. you check (userid = $username  in query). Is it OK?
  22. OK 1st you use variable $id before yuo set up it in 1st query ($query_payment) It cause thet query returns no rows and $payment_num is zero and you never go in while loop line $id = $_GET['id']; move before line $query_payment = ... 2nd  Before while loop $paysubtotal = $total (not payment yet) In while loop for each paymant you must subtract payment_amount from paysubtotal ($paysubtotal = $paysubtotal - $payment_amount;) insert line $paysubtotal = $total; before while loop change line $paysubtotal = $total - $payment_amount; in $paysubtotal = $paysubtotal - $payment_amount;
  23. try order by (prod_size_color + 0)
  24. move line[code]$paysubtotal = $total - $payment_amount;[/code] in if part [code]if ( $payment_id == "$id" ) { echo"$$payment_amount - $payment_date<br />";                 $paysubtotal = $total - $payment_amount; }[/code] btw you can add WHERE part in your SQL[code]$query_payment="SELECT id, payment_id, payment_amount, payment_date FROM customer_payments WHERE payment_id='$id'";[/code] and you don't need if statemans at all
×
×
  • 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.