Jump to content

dreamwest

Members
  • Posts

    1,223
  • Joined

  • Last visited

    Never

Posts posted by dreamwest

  1.    
    
    $sql = mysql_query("SELECT * FROM `Topic` WHERE `category_id`='{$category_id}' ORDER BY `id` DESC LIMIT 10")or die(mysql_error()); //remove or die() after testing
    
    $num = mysql_num_rows($sql);
    
    if($num ==0){
    echo 'No results';
    die();
    }
    
       while ($row = mysql_fetch_assoc($sql)){
       
       $topic_id = $row['id'];
       $topic_name = $row['topic_name'];
       $posts = $row['posts'];
       $mem_id = $row['mem_id'];
          
       $get_mem_name = mysql_query("SELECT * FROM `Member` WHERE `id`='{$mem_id}' ");
       $get_mem_row = mysql_fetch_assoc($get_mem_name);
       
       $mem_name = $get_mem_row['username'];
       
       $get_reply_mem = mysql_query("SELECT * FROM `Reply` WHERE `topic_id`='{$topic_id}' ");
       $get_results = mysql_num_rows($get_reply_mem);
       
       if ($get_results >= 1){
       
       $test = "works";
       
       }else{
        $test = "doesn't work";
       }
    echo $test."<br>";
    }//end while
    

  2. ok i tried this but all it return is "1"

     

    $arr[] = array('id' => 0, 'title' => funny);
    $latest[] = array('id' => 23, 'title' => second);
    
    $blend = array_merge($latest,$arr);
    $blend = shuffle($blend);
    print_r($blend);

  3. Why cant i shuffle a merged array?

     

    $arr[] = array('id' => 0, 'title' => funny);
    $latest[] = array('id' => 23, 'title' => second);
    
    $blend = array_merge($latest,$arr);
    print_r(shuffle($blend));

  4. Thanks! I think i undestand it now

    $srt = 1;
    $end = 10;
    while ($srt < $end) {
    
    $arr[]= array('q_id' => $srt, 'field2' => barry, 'field3' => german) ;
    ++$srt;		
    }//end while	
    print_r ($arr);

     

     

  5. Im trying to specify keys for associative arrays but ive never done it before other than via mysql

     

    This:

     

    	$srt = 1;
    $end = 10;
    while ($srt < $end) {
    
    $arr[]= $srt;
    ++$srt;		
    }//end while	
    print_r ($arr);

     

    Outputs: (10 loops)

    Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 )

     

    But how can i get it like this: (1 loop example)

    Array ( [0] => Array ( [q_id] => 1 [q_v_id] => 857434 [q_session] => fe13c9e53d1e6d0170a59f88c6327547 ) )

     

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