PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
mysql select query, only last row is viewed (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: mysql select query, only last row is viewed
#764
edryan (User)
Junior Boarder
Posts: 21
graphgraph
User Offline Click here to see the profile of this user
mysql select query, only last row is viewed 4 Months ago Karma: 0  
hi guyz,

i got problem with my select query...i successfully made the select query from a mysql database, but only the last record of the table of the database is displayed in the treeview...

i got this array from a my select query
Code:
$data = array(array($transid, $fname, $lname, $address, $contact, $company, $coid));
//i use this array to populate my data...
this is the way i populate the data from the database table $listStoreTrans is my model...
Code:
 //Populates the data
			for ($row=0; $row<count($data);++$row){
				$values = array();
				for ($col=0;$col<count($data[$row]);++$col){
					$values[] = $data[$row][$col];
				}
				$listStoreTrans->append($values);
			}

supposed to be all records from the database should be displayed on the tree view, but only the last record shows...HELP PLSSS...
 
  The administrator has disabled public write access.
#795
kksou (Admin)
Admin
Posts: 443
graph
User Online Now Click here to see the profile of this user
Re:mysql select query, only last row is viewed 3 Months, 3 Weeks ago Karma: 8  
You did not give enough codes to be able to figure out what might be the problem.

PHP has been stable enough. It doesn't do wierd thing without you programming it. So if it gives only one row of data, it just means that there's only one row of data.

So you might want to try the following:

1) Do a print_r($data) to see what's inside.

2) If $data is not correct, then check your codes that transfer the query results to the array.

3) If $data is correct, then just after "for ($col=0;$col<count($data[$row]);++$col){", do a
Code:
print "data[$row][$col] = ".$data[$row][$col]."\n";
Check if the values are correct.
    Regards,
      /kksou
       
        The administrator has disabled public write access.
      #798
      edryan (User)
      Junior Boarder
      Posts: 21
      graphgraph
      User Offline Click here to see the profile of this user
      Re:mysql select query, only last row is viewed 3 Months, 3 Weeks ago Karma: 0  
      SOLVED!

      im sori,i haven't displayed the codes...i just solved it..
      because i was trying to use an array to build the table..i made the array from the query inside the parent constructor...

      Code:
      //Some mysql query here
      $data=array(array($id,$fname,$lname...etc));
      $this->createTable($data);
      
      i tried it with a set of array with data already like on the example on how display data to tree view.. what i did is i put the mysql query inside the createTable function and populate the data there...
       
        The administrator has disabled public write access.
      Go to top Post Reply
      Powered by FireBoardget the latest posts directly to your desktop

      Blog - Forum - Privacy Policy - Contact Us
      Copyright © 2006-2009. kksou.com. All Rights Reserved