SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Ghz's Avatar
    Join Date
    Jun 2002
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Help me with this array plz

    Hey there,
    I would like to make a function which has many out puts. So I put the results in an array, My problem now is that I don't know how to print out each reults alone. That is to say I want to choose one variable from that array. Here is my function:

    PHP Code:
     function topic_st($topic_id) {
    require 
    "admin/config.php";
    $con=mysql_pconnect($config['db_server'],$config['db_user'],$config['db_password']) or die(mysql_error());
    mysql_select_db($config['db_name']);
    $c_query mysql_query("SELECT * FROM arts_comments WHERE art_id='$topic_id' && comment_to='art'");
    if(
    mysql_num_rows($c_query) >= $config['max_hot']) {
    $img "<img src='images/posticon_hot.gif' border='0' alt='Hot topic [".mysql_num_rows($c_query)."]'>";
    }else{
    $img "<img src='images/posticon.gif' border='0' alt='Post a comment'>";

     
    $num mysql_num_rows($c_query);
    $contents = array (
    "art_icon" => $img,
    "co_num" => $num,
    );
     
    return 
    $contents;

    I tried this:
    PHP Code:
     
    echo topic_st['art_icon']($row['id']); 
    but was invain. Can some tell me how to choose one variable from the array inside the function?

    Any help would be highly appreciated in advance,
    Ghz

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $data topic_st($row['id']);

    echo 
    $data['art_icon'];
    echo 
    $data['co_num']; 
    ... should do it.

  3. #3
    SitePoint Addict Ghz's Avatar
    Join Date
    Jun 2002
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WOW that was too easy...
    Thank youuuuuuuuuuuuuuuuuuuuuuuu so much I appreciate your help..

    Thanks again


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •