sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
try SELECT * FROM `table` ORDER BY (SELECT COUNT(`id`) FROM `table` a WHERE a.threadid=table.threadid) DESC
-
check how many times some houer pass between 2 diff dates
sasa replied to arikflorida's topic in PHP Coding Help
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); ?> -
[SOLVED] Help please! While loop not looping!
sasa replied to bennyboywonder's topic in PHP Coding Help
you use same variable name ($result) in both while loop try to make names diferent ($result1 and $result2) -
no. the error is thet betwen this two date is 2004-02-29. it cause wrong output
-
it stil output same results
-
3 * 365 = 1095 and 4* 365 = 1460 how years is 3?
-
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?
-
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?
-
Convert MySQL 14 digit timestamp into Readable format
sasa replied to mjurmann's topic in PHP Coding Help
try <?php echo date("D M j G:i:s T Y",strtotime($row_Recordset4['date_posted']));?> -
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;
-
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)
-
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'");
-
if you have line mysql_fetch_assoc($Recordset1); before for loop temowe it
-
can you use include? try[code]<?php $test = @include_once('/config.php'); if ($test) echo 'yes'; else echo 'no'; ?>[/code]
-
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]
-
try[code]foreach($arr_am as $ai => $aa) { // foreach($arr_id as $ai) // { $x = 0; while($aa > $x) { echo $arr_id[$ai]; $x++; } // } } [/code]
-
[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]
-
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]
-
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?
-
change print $str.' = '.eval($str.';').'<br />'; to print $str.' = '; eval('print '.$str.';'); print '<br />';
-
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
-
you check (userid = $username in query). Is it OK?
-
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;
-
try order by (prod_size_color + 0)
-
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