How to extract the results...

Discussion in 'PHP' started by adamjblakey, Dec 11, 2007.

  1. #1
    Hi,

    Please can someone tell me how to extract results from this:

    function selects($select) {
    	$this->result = mysql_query($select,$this->connection);
    	$this->row = mysql_fetch_assoc($select);
    	}
    
    function getRes() {
    	while ($res = mysql_fetch_array($this->result)) {
    	$this->reser[] = $res;
    			}
    	return $this->reser;
    		}
    
    $current = new database;
    $current->selects("SELECT * FROM table");
    $cresults = $current->getRes();
    
    
    Code (markup):
    How would a print out the results?

    Cheers,
    Adam
     
    adamjblakey, Dec 11, 2007 IP
  2. Gawk

    Gawk Peon

    Messages:
    427
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    foreach ($cresults as $row) {
    echo $row[col1] . "," . $row[col2] . "<br>";
    }
    PHP:
    Change col1, col2 to your column names etc.
     
    Gawk, Dec 11, 2007 IP
  3. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #3
    What i am trying to do is the following which i cannot work out how to do.

    Basically with the above i want to loop through the results checking against another table to see if any of the "country" fields match.

    So when i have the results from $cresults i need to check them against table2 to see if the country fields match.
     
    adamjblakey, Dec 11, 2007 IP