troubleshooting Question

EditableGrid how to fetch rows from MySql in php

Avatar of SniperCode Sheva
SniperCode Sheva asked on
14 Comments1 Solution510 ViewsLast Modified:
I am trying to do an editable grid table in order to modify directly.
There is a field which I need to list all of it content so that I can select one.
Look at my code :

 function fetch_pairs($mysqli,$query){
    	if (!($res = $mysqli->query($query)))return FALSE;
    	$rows = array();
    	while ($row = $res->fetch_assoc()) {
    		$first = true;
    		$key = $value = null;
    		foreach ($row as $val) {
    			if ($first) { $key = $val; $first = false; }
    			else { $value = $val; break; } 
    		$rows[$key] = $value;
    	return $rows;
    $grid->addColumn('product-name', 'Product', 'string' , fetch_pairs($mysqli,'SELECT name FROM table_product'),true); 

Open in new window

In my database I have two tables:

 But the list is not appearing.
I am getting this error:
Could not load JSON from url 'loaddata.php?db_tablename=table_add'

Any idea why ?

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros