Get KoolPHP UI with 30% OFF!

Dynamic data sources with KoolGrid

Timothy Graber
I am wanting to use a combo box that pulls data from a secondary table (Foreign key lookup - using a join statements in mySQL), so I consulted the Ajax Advanced example. When I create a page and run it with the example code, it is full of errors.
Warning: mysql_set_charset() expects parameter 2 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_query() expects parameter 2 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_fetch_field() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_free_result() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_error() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_set_charset() expects parameter 2 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_query() expects parameter 2 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_result() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_free_result() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_error() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_query() expects parameter 2 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_free_result() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_error() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Warning: mysql_error() expects parameter 1 to be resource, null given in /var/www/KoolControls/KoolGrid/koolgrid.php on line 1
Then, below this there is a small grid control that gives the option to add a new record, which gives the following... there are no choices in the drop down boxes for continent and country (see below/bottom) I have checked my Kool database and it has values in the appropriate tables, also the database is working for other examples that use database lookups.
Other than copying the code and creating a php page, I have not altered the provided sample code.
Inserting a new customer
Name:
Continent:
Country:
ConfirmCancel
Add New Record Refresh
First Prev Next LastPage 0 in 0, items 0 to of .
Posted Nov 27, 2015 Kool
Anthony Amolochitis
That error sounds like a bad sql query. I would try to run that query in phpMyAdmin to make sure it is right.
You could also write your own AJAX script to run a simple php command to return html to create a new combo box from the server.
Then change the innerhtml of a div to the new combo box.
Here is sample Javascript to build the xml http object :
/**
 * Get an xml http object for ajax requests
 * @returns {XMLHttpRequest|ActiveXObject}
 */
function GetXmlHttpObject()
{
    /**
     * @type XMLHttpRequest|ActiveXObject
     */
    var xmlhttp;
    
    if (window.XMLHttpRequest)
    {   // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {   // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    return xmlhttp ;
}
function GetNewCobmoBoxList( someId )
{
    /**
     * @type XMLHttpRequest|ActiveXObject
     */
    var xmlhttp = GetXmlHttpObject() ;
            
    var url = "SomePhpScript.php" ;
    var postData = "someId =" + someId ;
    xmlhttp.open( "POST", url , true );
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send(postData);
    
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            //
            // display the new returned html
            //            
            document.getElementById("DisplayDivToFillWithNewHtml").innerHTML = xmlhttp.responseText ;            
        }
    }
    
}
Posted Nov 28, 2015 Kool
Timothy Graber
I guess I should re-phrase the question.The code I used is pasted directly from the sample provided in the page under the Description and Sample code on the documentation for KoolGrid.
kool/Examples/KoolGrid/Advanced/Ajax_Template/index.php
The pasted code produces the errors above and I tested the SQL queries. I will dig into the page itself (index.php) to see what the differences are.
I think, though, if sample code is provided, it should work.
Edit - I did get things to work, however, it needed more adjusting than the notes provided suggested. Your suggestion of an SQL query issue made sense.
1. The original script requires several settings from the examples framework to function, namely the db connection, database selection and also some of the code in the HTML section needs to be adjusted to make this a 'stand alone' script.
- Define the database server connection - $db_con = mysql_connect("server","username","password");
- Define the database to connect to - mysql_select_db("dbKool",$db_con);
- Then on line 101 of example.php (under the Examples|KoolGrid|Advanced|Ajax_Template), change the relative path of this to one that matches the correct one based on where your script is $myPanel->setLoading("../../../../KoolControls/KoolAjax/loading/5.gif");
I hope this helps someone like me who is new to this framework.
BTW: I love all the controls you have made. They are helping me make a really nice framework for my application and database.
Posted Nov 28, 2015 , edited Nov 28, 2015 Kool
Javier
Optimization in business brings only a positive result, but in our time its absence reduces the success rate of any project. So that this does not become a problem for you, you can use an outsourcing service that will solve the tasks of automating project services and much more. Your project will be handled by the best team of specialists with vast experience in various areas of programming. Moreover, you can personally choose the candidates you need and the skills you need. So, click site .
Posted Apr 17, 2023 , edited Apr 17, 2023 Kool
Newton
Have you ever considered how remote assistance could benefit your business? Our skilled team of virtual support agents are available around the clock to provide your customers with the assistance they need, no matter where they are in the world. With our advanced technology, you can stay connected with your customers in real-time, ensuring their satisfaction and loyalty. >>> try this website
Posted Apr 22, 2023 Kool
Gregory
Good afternoon, if your business needs high-quality staff services, then I strongly recommend paying attention to visit this site! Hire experienced specialists from Ukraine right now! Remote recruitment of IT specialists in Eastern Europe saves a lot of costs throughout the entire process and is a highly effective choice! I hope this information was useful to you!
Posted Apr 22, 2023 Kool
Mia
Hello everyone! By hiring remote machine learning engineers, businesses can access a global pool of talent and expertise. This allows to build a highly-skilled team without the overheads associated with traditional recruitment methods. Additionally, remote work allows for greater flexibility and can result in higher employee satisfaction and retention. You can try this company and use this link. Thank you! I hoped my advice would be useful.
Posted Apr 24, 2023 Kool
andrew
With the rise of remote work, fintech developers can now work from anywhere in the world, giving them the flexibility to pursue their passions while delivering exceptional work to their clients. This allows companies to tap into a global talent pool, finding the best and most qualified candidates for their projects. look here
Posted Apr 26, 2023 Kool