Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
Example Twitter Bootstrap grid with json and mysql
posted

Hello! I'm trying to use the example of the grid (http://www.igniteui.com/grid/twitter-bootstrap), but I need the data displayed in it come from a database, someone has already done this or could help me explaining how to build the php to grab the database and play the grid?

I would be very grateful if someone could help me ˆˆ

ps .: am beginner and could not understand the examples I found like this (since it only contains the database connection and does not indicate how prepare the json data to insert into the grid):

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());

mysql_select_db($dbname) or die (mysql_error());

$data = mysql_query($q) or die(mysql_error()); 

$recCount = mysql_query($countQuery) or die (mysql_error());

where $q holds your query string such as SELECT .... which selects the data rows, and $countQuery holds the query which returns how many rows in total you have (important for paging / summaries, etc.) 

$rows = array();

while($r = mysql_fetch_assoc($data)) {

    $rows[] = $r;

}

header("Content-type: application/json");

$arr = mysql_fetch_array($recCount);

$response = array("totalCount" => $arr[0], "records" => $rows);

echo json_encode($response);

mysql_close($conn);

Parents Reply Children