php help

Discussion in 'PHP' started by red_fiesta, May 3, 2007.

  1. #1
    I have this code

       	<?
    
    	    
    		$strSQL5 = "SELECT  distinct Training_Date from trainingattendance WHERE Training_Date between '".date('Y-4-')."01' and '".date('Y-m-')."31'";
    	
    		$Conn=mysql_connect("localhost","***","***");
    		mysql_select_db("***",$Conn);
    		$result5 = mysql_query($strSQL5);	
    		
    	 			
    ?>
    
     	
    <? while($row5 = mysql_fetch_assoc($result5)){ 
    
    
    
    someArray[i] = $row5['Training_Date'];
    i++;
    
    							  
    
    	 } ?>
    Code (markup):
    the array make the page crash? why? If i change the

    
    someArray[i] = $row5['Training_Date'];
    i++;
    Code (markup):
    to

    print $row5['Training_Date'];
    
    Code (markup):
    it works... but i need to save in an array...
     
    red_fiesta, May 3, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php
    
    $strSQL5 = "SELECT  distinct Training_Date from trainingattendance WHERE Training_Date between '".date('Y-4-')."01' and '".date('Y-m-')."31'";
    	
    $Conn=mysql_connect("localhost","***","***");
    mysql_select_db("***",$Conn);
    $result5 = mysql_query($strSQL5);	
    		
    while($row5 = mysql_fetch_assoc($result5)){ 
        $someArray[] = $row5['Training_Date'];
    } 
    
    ?>
    PHP:
     
    rodney88, May 3, 2007 IP
  3. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #3
    someArray !!!!
     
    nabil_kadimi, May 3, 2007 IP
  4. red_fiesta

    red_fiesta Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4


    thanks..

    how do I then return the length of the array.. i want to do something like..

    while (i <= less than my last array?? ){

    print $someArray

    i++;

    }
     
    red_fiesta, May 3, 2007 IP
  5. rashmirani

    rashmirani Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If anyone know how to use curl to fetch page content from authanticate url please guide me. It's urgent.
     
    rashmirani, May 3, 2007 IP
  6. red_fiesta

    red_fiesta Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    That is a seperate question and should be in a seperate post.

    It doesnt help my question....
     
    red_fiesta, May 3, 2007 IP
  7. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #7
    All variables in PHP must start with $. You can use the count() function to get the number of values in the array and a for() loop to go through them.

    $lastArray = count($oldArray);
    for ( $i = 0 ; $i < $lastArray; $i++ ) {
         print $newArray[$i];
    }
    PHP:
     
    rodney88, May 3, 2007 IP
  8. Spikeon

    Spikeon Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    its obvious...
    you need to declare i as a variable, like $i
    also, someArray should be $someArray
     
    Spikeon, May 3, 2007 IP