display category on index.php

Discussion in 'PHP' started by Hannaspice, May 21, 2009.

  1. #1
    Hi guys,

    I have categories and titles tables, category belongs to titles table where it equals id field from categories table and catname belongs to categories table, in the end I would like to display catname from the categories table for each title. But there is some problems with it...

    $sql = "SELECT category FROM titles WHERE `status`='A'";
    $result = dbQuery($sql);
    				 
    		 for ($i=0; $i<mysql_num_rows($result);$i++) {
    		 
    		 $cat_id = mysql_result($result, $i, "category");
    		 
    
    		 $sqll = "SELECT catname FROM categories WHERE `status`='A' AND id='$cat_id'";
    	     $res = dbQuery($sqll);
    		
    	     $catname = mysql_result($res, 0, "catname");
    		 $out.= "<p>" . $catname . "</p>\n";}
    PHP:

    In my index.php, there is a notice:
    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 11 in C:\AppServ\www\starttim\index.php on line 76

    line 76: $catname = mysql_result($res, 0, "catname");;

    Anybody please help!!!:rolleyes:
     
    Hannaspice, May 21, 2009 IP
  2. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Problem is...which line is 76? You call mysql_result two times...
     
    NatalicWolf, May 21, 2009 IP
  3. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'd check the query by using "or die(mysql_error());"
     
    NatalicWolf, May 21, 2009 IP
  4. Hannaspice

    Hannaspice Active Member

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #4
    I dun know what is wrong with it.
     
    Hannaspice, May 21, 2009 IP
  5. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I can help you, please IM me(not PM) on one of the messengers in my profile.
     
    NatalicWolf, May 21, 2009 IP