Hi guys,
I’m make website which is functional and I’m make all what I wanted.All work just like I wanted.But now I want to improve my code optimization.
I have page where admin can see log’s(For example connection logs,ban logs,etc)
For every logs I’m make new .php file
/admin/logs/connection.php
/admin/logs/ban.php
And I have 20-25 same files which have 90% similar code.I want to make it in only one file ( > /admin/logs.php?ID=1
/admin/logs.php?ID=2
etc.
Code which is not same in all files
1.Who have permit to see it log
if($user['Admin'] == "3" )
{
//If admin = 3 ,he can see it logs,other users get : You don't have permission to view this log
}
2.MySQL Query
SELECT * FROM logs WHERE Category = 'BanLogs'
//example,so fory every log there is different Category,of course
3.Tittle
<title>Ban logs</title>
4.Print from Query(example)
<?php if (!empty($logs)) { foreach ($logs as $log) { ?>
<tr>
<td><?php echo $log['ID']; ?></td>
<td><?php echo $log['Username']; ?></td>
<td><?php echo $log['Country']; ?></td>
<td><?php echo $log['Date']; ?></td>
</tr>
<?php } } ?>
5.JavaScript
<script>
$(document).ready(function () {
$('#dataTables-connection').dataTable(
{ "order": [[ 0, "desc" ]],
"aoColumnDefs": [{ "bVisible": false, "aTargets": [0] }],
"pageLength": 50,
"lengthMenu": [[50, 200, 500, 1000, -1], [50, 200, 500, 1000,"All"]],
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
if ( aData[4] > 8)
{
$('td', nRow).css('background-color', 'Red');
}
}
});
});
</script>
So my question is how to make this in one file? (logs?ID=1 ) etc…What is best way for it…
I don’t know where I can read more about this.Tutorials or something like that.(I don’t know for what to search )
Thank you very much