Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sasa

  1. Because it's not yet been exactly three years. Those amounts are rounded down, that's what Floor does. You know by looking at it that if tomorrow is their birthday, they are not yet 4 years old. However, since we don't know the time they were born, we assume it was midnight, and when you round out the days, it turns out to be 1460. If you put in a different date such as 2003-03-05, you'll see the days go down, because it's not quite four years yet. Their age is still 3.

     

    no. the error is thet betwen this two date is 2004-02-29.

    it cause wrong output

  2. 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?

     

  3. 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;

  4. 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)

  5. 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]
  6. [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]
  7. 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
  8. 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;
  9. 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.