shahedifar
پنج شنبه 04 تیر 1394, 23:43 عصر
اساتید یک سوال دارم ازتون.این کدهارو ببینید.فایل proccess.php هست.
<?phprequire_once('config.php');$query = mysql_query("select * from code where active='1' AND status='1' order by date_end asc,time_end asc");while($fetch = mysql_fetch_array($query)){ $output[] = array ($fetch[4],$fetch[5],$fetch[12],$fetch[13],$fetch[14],$fetch[10],$fetch[11],$fetch[2],$fetch[3],$fetch[19],$fetch[20],$fetch[21],$fetch[22],$fetch[9]);}echo json_encode($output);?>
این هم فایل index.html هست.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Populate jQuery datatable with JSON data :: jQuery Ajax PHP</title><link rel="stylesheet" href="jquery.dataTables.css" /><link rel="stylesheet" href="bootstrap.min.css" /><link rel="stylesheet" href="http://getbootstrap.com/assets/css/docs.css" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script><script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script><script src="jquery.dataTables.js" type="text/javascript"></script><script type="text/javascript">$(document).ready(function() { //$('#jsontable').dataTable( { // "ajax": 'arrays.txt' // } );
var oTable = $('#jsontable').dataTable(); //Initialize the datatable
$('#load').on('click',function(){ var user = $(this).attr('id'); if(user != '') { $.ajax({ url: 'process.php?method=fetchdata', dataType: 'json', success: function(s){ console.log(s); oTable.fnClearTable(); for(var i = 0; i < s.length; i++) { oTable.fnAddData([ s[i][0], s[i][1], s[i][2], s[i][3], s[i][4], s[i][5], s[i][6], s[i][7], s[i][8], s[i][9], s[i][10], s[i][11], s[i][12], s[i][13] ]); } // End For }, error: function(e){ console.log(e.responseText); } }); } });});</script>
<style type="text/css">.container { width: 980px; margin:0 auto; }#demo-header {height: 150px;width: 100%;background: url('http://www.jquery.com/cdn/2013/11/jap-logo.png') center no-repeat;margin-bottom: 25px;border-bottom: 1px solid #999;padding-bottom: 25px;
}.btn { margin-bottom:30px}.white{ background: transparent url(../themes/light.png) repeat scroll 0 0; }</style></head>
<body><div id="demo-header"></div><div class="container"><div class="white"><input type="button" class="btn btn-primary" value="Load Match" id="load"/><table id="jsontable" class="display table table-bordered" cellspacing="0" width="10%"> <thead> <tr> <th>country</th> <th>ereee</th> <th>errrr</th> <th>feee</th> <th>eeee</th> <th>ffff</th> <th>dddd</th> <th>ffff</th> <th>fddd</th> <th>mihi</th> <th>india2.5</th> <th>russ+4.5</th> <th>engl_4.5</th> <th>country</th> </tr>
</thead> <tfoot> <tr> <th>country</th> <th>ereee</th> <th>errrr</th> <th>feee</th> <th>eeee</th> <th>ffff</th> <th>dddd</th> <th>ffff</th> <th>fddd</th> <th>mihi</th> <th>india2.5</th> <th>russ+4.5</th> <th>engl_4.5</th> <th>country</th> </tr> </tfoot> </table></div></div></body></html>
متوجه هستین که سورس دیتا تیبل هست.فقط اطلاعاتی که از دیتابیس میخونه بدون لینک هست.الان میخوام دقیقا همین fetch ها رو لینک دار کنم که بشه کلیک کرد.نظر شما چی هست؟محتاج راهنمایی هستیم.
<?phprequire_once('config.php');$query = mysql_query("select * from code where active='1' AND status='1' order by date_end asc,time_end asc");while($fetch = mysql_fetch_array($query)){ $output[] = array ($fetch[4],$fetch[5],$fetch[12],$fetch[13],$fetch[14],$fetch[10],$fetch[11],$fetch[2],$fetch[3],$fetch[19],$fetch[20],$fetch[21],$fetch[22],$fetch[9]);}echo json_encode($output);?>
این هم فایل index.html هست.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Populate jQuery datatable with JSON data :: jQuery Ajax PHP</title><link rel="stylesheet" href="jquery.dataTables.css" /><link rel="stylesheet" href="bootstrap.min.css" /><link rel="stylesheet" href="http://getbootstrap.com/assets/css/docs.css" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script><script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script><script src="jquery.dataTables.js" type="text/javascript"></script><script type="text/javascript">$(document).ready(function() { //$('#jsontable').dataTable( { // "ajax": 'arrays.txt' // } );
var oTable = $('#jsontable').dataTable(); //Initialize the datatable
$('#load').on('click',function(){ var user = $(this).attr('id'); if(user != '') { $.ajax({ url: 'process.php?method=fetchdata', dataType: 'json', success: function(s){ console.log(s); oTable.fnClearTable(); for(var i = 0; i < s.length; i++) { oTable.fnAddData([ s[i][0], s[i][1], s[i][2], s[i][3], s[i][4], s[i][5], s[i][6], s[i][7], s[i][8], s[i][9], s[i][10], s[i][11], s[i][12], s[i][13] ]); } // End For }, error: function(e){ console.log(e.responseText); } }); } });});</script>
<style type="text/css">.container { width: 980px; margin:0 auto; }#demo-header {height: 150px;width: 100%;background: url('http://www.jquery.com/cdn/2013/11/jap-logo.png') center no-repeat;margin-bottom: 25px;border-bottom: 1px solid #999;padding-bottom: 25px;
}.btn { margin-bottom:30px}.white{ background: transparent url(../themes/light.png) repeat scroll 0 0; }</style></head>
<body><div id="demo-header"></div><div class="container"><div class="white"><input type="button" class="btn btn-primary" value="Load Match" id="load"/><table id="jsontable" class="display table table-bordered" cellspacing="0" width="10%"> <thead> <tr> <th>country</th> <th>ereee</th> <th>errrr</th> <th>feee</th> <th>eeee</th> <th>ffff</th> <th>dddd</th> <th>ffff</th> <th>fddd</th> <th>mihi</th> <th>india2.5</th> <th>russ+4.5</th> <th>engl_4.5</th> <th>country</th> </tr>
</thead> <tfoot> <tr> <th>country</th> <th>ereee</th> <th>errrr</th> <th>feee</th> <th>eeee</th> <th>ffff</th> <th>dddd</th> <th>ffff</th> <th>fddd</th> <th>mihi</th> <th>india2.5</th> <th>russ+4.5</th> <th>engl_4.5</th> <th>country</th> </tr> </tfoot> </table></div></div></body></html>
متوجه هستین که سورس دیتا تیبل هست.فقط اطلاعاتی که از دیتابیس میخونه بدون لینک هست.الان میخوام دقیقا همین fetch ها رو لینک دار کنم که بشه کلیک کرد.نظر شما چی هست؟محتاج راهنمایی هستیم.