I have my table set up like this:

Table: eventreg
Columns: id, userchar

I need to call the id and read the userchar multiple times so the entries will look like this:

id userchar
2 6
4 0
6 4
2 7
3 9

i need the mysql call to call the id multiple times and spit out the userchar numbers so my other call can pull the userchar number from another table...

Hope you understand...

    $sql ="select * from eventreg";
    $result = mysql_query($sql,$conn);
    while ($row=mysql_fetch_array($result)){
    $userchar = $row["userchar"];

    $sql2 = "select * from othertable where userchar = $userchar";
    $result2 = mysql_query($sql2,conn);
    while $row2=mysql_fetch_array($result2){
    //do other stuff
    }

    assumption is that you are looking up one value at a time...

    hth

      function read_eventreg($id, &$char, &$eventreg) {
      if (!$id) {
      $err = ERR_ID_BLANK;
      } elseif (eregi("[[:digit:]]", $id)) {
      $err = ERR_ID_INVALID;
      } else {
      $query = "select userchar";
      $query .= " from eventreg";
      $query .= " where id = $id";

                 query_db($query, $char);
      
                 $userc = $char["userchar"];
      
                 $query  = "select id, name, surname, race, class, level";
                 $query .= "  from chars";
                 $query .= " where id = $userc";
                 $query .= " order by name asc";
      
                 $eventreg["count"] = query_db($query, $eventreg, true);
      
          }
          return $err;

      }

      This is how i have mine but it will only spit out one i need it to spit out more than one

        
        
        $stack = array ( );
        while ( $row = mysql_fetch_assoc ( $result ) )
        {
           $stack[] = $row
        }
        
        

        It's much faster to get all of the data in one call. Simply use one of the fetching functions to create a 2 dimension array. You can then use some sort of loop to turn the information into output.

          I have no idea how to use that little piece of code can you put it in that function and explain it 🙂

            Write a Reply...