Jump to content

phpretard

Members
  • Posts

    821
  • Joined

  • Last visited

    Never

Posts posted by phpretard

  1. I am trying to display the date like - 08-01-2009 by calling a function with a var.

     

    I know the code below is wrong but it's what I'm working with.

     

     

    
    <?php
    
    function myDate($startdate){
    
        echo "The date is ". $startdate;
    
    	$startdate="2009-08-01 07:27:40";
    	$predate=explode(' ', $startdate);
    	$splitdate=explode('-', $predate[0]);
    	$redeemDate="$splitdate[1]-$splitdate[2]-$splitdate[0]";
    	$new_date="$startdate";
    	    
    }
    
    myDate($new_date);
    
    ?>
    
    

     

    Thank you!

  2. One loop is $title the other is $stitle

     

    I have narrowed it down and this doesn't even work...

     

    - I am checking a row in the DB for zero or one.

    - if it's 0 it should display a div.

    - else it should display the other div.

     

    I am sure the tables are setup right because if I change:

     

    $title['sub_cat'] == 0 - TO - $title['sub_cat'] == 1

     

    It displays the TEST but not the other...

     

    
    $page_title = mysql_query("select * from category where id='".intval($_GET['c'])."' ");
    while($title = mysql_fetch_assoc($page_title))
    {
    if ($title['sub_cat'] == 0){ // ZERO CHECK
    echo"<div>".$title['long_name']."</div>";
    
                 }else{echo"<div>TEST</div>";}
    
    }
    
    mysql_free_result($page_title);
    
    

  3. Why doesn't tis work???

     

    
    connect();
    
    $page_title = mysql_query("select * from category where id='".intval($_GET['c'])."' ");
    while($title = mysql_fetch_assoc($page_title))
    {
    if ($title['sub_cat'] == 0){
    	echo"<div style=\"color:#A00201; font-style:italic; padding-top:5px;; font-size:22px; font-weight:bold;\">".$title['long_name']."<hr /></div>";
    }else{
    	$sub_title = mysql_query("select * from category_sub where cat_id='".$title['id']."' ") or die(mysql_error());
    	while($stitle = mysql_fetch_assoc($sub_title));
    		{
    		echo"<div style=\"color:#A00201; font-style:italic; padding-top:5px;; font-size:22px; font-weight:bold;\">".$stitle['sub_name']."TEST<hr /></div>";
    		}
    	mysql_free_result($sub_title);		
    	}
    }
    
    mysql_free_result($page_title);
    
    

     

    Its driving me mad!!!

  4. I need to print out the time but I cant figure???

     

    
    $calls['stamp']="2009-07-26 12:02:53";
    
    $startdate=$calls['stamp'];
    $predate=explode(' ', $startdate);
    $splitdate=explode('-', $predate[0]);
    $Date="$splitdate[1]-$splitdate[2]-$splitdate[0]";
    
    This prints out "07-26-2009";
    
    

     

    I need the time as well.  Any help?

  5. Not tested but should give you an idea...

     

    
    <?php
    if (isset($_POST['submit'])){
    
    //connect to the DB
    
    $get_ip=mysql_query("select * from ip_table where ip='".$_POST['clicker']."' ");
    
    $num_rows = mysql_num_rows($get_ip);
    
       if ($num_rows > 19){
          $disable="disabled";
          $alert="<script>alert('You are hurting my clicker')</script>";
    
       }else {
           // $count_a=query the db for the ip and the count
           $count=$count_a + 1;
           $insert=mysql_unbuffered_query("update ip_table set count='$count' where ip='".$_SERVER['REMOTE_ADDR']."' ");
    
    }
    
    mysql_free_result($get_ip);
    
    }
    ?>
    
    <form>
    <input type="hidden" name="clicker" value="<? echo $_SERVER['REMOTE_ADDR']; ?>" />
    <input type="submit" name="submit" <? echo $disable; ?> />
    </form>
    
    <?
    echo $alert;
    ?>
    

  6. I am validating a form with PHP and it contains check boxes, text, radios etc...

     

    The short logic is:

    -At least one check box has to be checked

    -At least one radio has to be ticked

    -And one text box has to be filled

     

    If I check a box and tick a radio but do not fill in the text box it validates fine but the check box becomes "un-checked" afterwards.

     

    So my question is what is the recommended way keep check boxes checked and radios ticked while validating the rest of the form?

     

    I know the hard way to do it but I was hoping for some advise on it.

     

    <input type="checkbox" name="referred[]" value="Internet" /> Internet
    <input type="checkbox" name="referred[]" value="Radio" /> Radio
    <input type="checkbox" name="referred[]" value="Television" /> Television
    <input type="checkbox" name="referred[]" value="Billboard" /> Law Talk
    <input type="checkbox" name="referred[]" value="" /> Billboard
    <input type="checkbox" name="referred[]" value="Newspaper" /> Newspaper
    <input type="checkbox" name="referred[]" value="Phone Book" /> Phone Book
    <input type="checkbox" name="referred[]" value="Attorney Referral" /> Attorney Referral
    <input type="checkbox" name="referred[]" value="Friend" /> Friend
    

     

     

    Thanks.

  7. I send newsletters through a service and they provide a report of how many people opened the email.  I was perplexed as to how they could tell until I discovered a 1X1 blank gif at the bottom of the newsletter.

     

    <img src="http://app.streamsend.com/v/1477632/pqBnIm6/d5Fs"/>
    

     

    any ideas as to how that picture could ("insert into...?

     

    I would like to track who opens email as well.

     

    Thank you!

  8. When I click "modules >> payment" instead showing me the different modules it just prints:

     

    Module Directory: DIR_FS_CATALOGincludes/modules/payment/

     

    I see all the moldules in that folder but it doesn't show them.

     

    Any suggestions?

  9. Thank you very much.

     

    
    echo $first_day = date("Y-m-d h:i:s", strtotime("1 ". date("F Y")));
    echo '<br />';
    echo $last_day = date("Y-m-d h:i:s", strtotime(date("t F Y ")));
    
    above outputs:
    2009-06-01 12:00:00
    2009-06-30 12:00:00
    
    I dont quite understand: "strtotime(date("t F Y ")));"
    
    Where can I adjust to output?:
    2009-06-01 12:00:00
    2009-06-30 11:59:59
    
    

     

    Thanks again :)

  10. I would like to display the current month's 1st and last day.

     

    It has to be simple I just cant figure it out based on php.net's site

     

    
    $First=date('Y-m-d h:i:s');
    $Last=date('Y-m-d h:i:s');
    
    echo $First should be "2009-6-1 12:01"
    echo $Last should be "2009-6-30 11:59"
    
    

     

    Thank you for looking.

  11. Look what I found:

     

    
    <?
    function convertNumber($num)
    {
       list($num, $dec) = explode(".", $num);
    
       $output = "";
    
       if($num{0} == "-")
       {
          $output = "negative ";
          $num = ltrim($num, "-");
       }
       else if($num{0} == "+")
       {
          $output = "positive ";
          $num = ltrim($num, "+");
       }
       
       if($num{0} == "0")
       {
          $output .= "zero";
       }
       else
       {
          $num = str_pad($num, 36, "0", STR_PAD_LEFT);
          $group = rtrim(chunk_split($num, 3, " "), " ");
          $groups = explode(" ", $group);
    
          $groups2 = array();
          foreach($groups as $g) $groups2[] = convertThreeDigit($g{0}, $g{1}, $g{2});
    
          for($z = 0; $z < count($groups2); $z++)
          {
             if($groups2[$z] != "")
             {
                $output .= $groups2[$z].convertGroup(11 - $z).($z < 11 && !array_search('', array_slice($groups2, $z + 1, -1))
                 && $groups2[11] != '' && $groups[11]{0} == '0' ? " and " : ", ");
             }
          }
    
          $output = rtrim($output, ", ");
       }
    
       if($dec > 0)
       {
          $output .= " point";
          for($i = 0; $i < strlen($dec); $i++) $output .= " ".convertDigit($dec{$i});
       }
    
       return $output;
    }
    
    function convertGroup($index)
    {
       switch($index)
       {
          case 11: return " decillion";
          case 10: return " nonillion";
          case 9: return " octillion";
          case 8: return " septillion";
          case 7: return " sextillion";
          case 6: return " quintrillion";
          case 5: return " quadrillion";
          case 4: return " trillion";
          case 3: return " billion";
          case 2: return " million";
          case 1: return " thousand";
          case 0: return "";
       }
    }
    
    function convertThreeDigit($dig1, $dig2, $dig3)
    {
       $output = "";
    
       if($dig1 == "0" && $dig2 == "0" && $dig3 == "0") return "";
    
       if($dig1 != "0")
       {
          $output .= convertDigit($dig1)." hundred";
          if($dig2 != "0" || $dig3 != "0") $output .= " and ";
       }
    
       if($dig2 != "0") $output .= convertTwoDigit($dig2, $dig3);
       else if($dig3 != "0") $output .= convertDigit($dig3);
    
       return $output;
    }
    
    function convertTwoDigit($dig1, $dig2)
    {
       if($dig2 == "0")
       {
          switch($dig1)
          {
             case "1": return "ten";
             case "2": return "twenty";
             case "3": return "thirty";
             case "4": return "forty";
             case "5": return "fifty";
             case "6": return "sixty";
             case "7": return "seventy";
             case "8": return "eighty";
             case "9": return "ninety";
          }
       }
       else if($dig1 == "1")
       {
          switch($dig2)
          {
             case "1": return "eleven";
             case "2": return "twelve";
             case "3": return "thirteen";
             case "4": return "fourteen";
             case "5": return "fifteen";
             case "6": return "sixteen";
             case "7": return "seventeen";
             case "8": return "eighteen";
             case "9": return "nineteen";
          }
       }
       else
       {
          $temp = convertDigit($dig2);
          switch($dig1)
          {
             case "2": return "twenty-$temp";
             case "3": return "thirty-$temp";
             case "4": return "forty-$temp";
             case "5": return "fifty-$temp";
             case "6": return "sixty-$temp";
             case "7": return "seventy-$temp";
             case "8": return "eighty-$temp";
             case "9": return "ninety-$temp";
          }
       }
    }
          
    function convertDigit($digit)
    {
       switch($digit)
       {
          case "0": return "zero";
          case "1": return "one";
          case "2": return "two";
          case "3": return "three";
          case "4": return "four";
          case "5": return "five";
          case "6": return "six";
          case "7": return "seven";
          case "8": return "eight";
          case "9": return "nine";
       }
    }
    ?>
    
    $Spell=convertNumber("395.00");
    
    echo $Spell;
    

     

     

  12. All the variable print so I don't know what the problem is.

     

    Do you see any issues?

     

    
    // message
    $message = '<html><body>
    <p>Greetings '.$appraiser['FirstName'].' '.$appraiser['LastName'].',</p>
    
    </body></html>';
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'To: '.$appraiser['Company'].' <'.$appraiser['Email'].'>\r\n';
    $headers .= 'From: '.$broker['Company'].' <'.$FromEmail.'>\r\n';
    
    // Mail it
    $send=mail($appraiser['Email'], "New Appraisal Order", $message, $headers);	
    
    

     

    Thanks!

  13. This did it.

     

    I insert it in mysql as the expired time and compair against it.

     

    
    connect();
    
    $get_time_limit=mysql_query("select time1 from preferences");
    $timelimit=mysql_fetch_assoc($get_time_limit);
    
    $exp=time() + (1 * $timelimit['time1'] * 60 * 60);
    $expired=date('Y-m-d H:i:s', $exp);
    
    mysql_free_result($get_time_limit);
    
    

     

    Thank you for looking at it.

  14. I am trying to add minutes or hours to $current.

     

    This time should expire after $var hours.

     

    So I need this to compare now() to $expired

     

    
    $current="2009-05-30 09:32:23";
    
    $exired="2009-05-30 09:32:23" + $hours;
    
    
    
    if ($expired >= now()){
      times up
    
    }else{
      your still good
            }
    
    

     

    any suggestion?

×
×
  • 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.