alexa-tracking

Main Content

1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/53c35c4e6208815d168b45e2/tanya-php
Tanya Php
permisi para master php..saya mau tanya....saya ingin menambahkan kolom lampiran file pdf..tolong pencerahannya..terima kasih..berikut saya lampirkan gambar dan sourcodenya.....

*sourcecode menampilkan field2 database

<html>
<head>

<link href="themes/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
<link href="Scripts/jtable/themes/lightcolor/blue/jtable.css" rel="stylesheet" type="text/css" />

[removed][removed]
[removed][removed]
[removed][removed]

</head>
<body>
<div id="KoranTableContainer" style="width: 1200px;"></div>
[removed]

$(document).ready(function () {

//Prepare jTable
$('#KoranTableContainer').jtable({
title: 'Table of Kliping',
paging: true,
pageSize: 10,
sorting: true,
defaultSorting: 'A3 ASC',

//selectOnRowClick: false, //Enable this to only select using checkboxes
actions: {
listAction: 'KlipingActions.php?action=list',
createAction: 'KlipingActions.php?action=create',
updateAction: 'KlipingActions.php?action=update',
deleteAction: 'KlipingActions.php?action=delete'
},
fields: {
ID: {
key: true,
create: false,
edit: false,
list: false
},
A1: {
title: 'Koran',
width: '15%',
options: {'1':'Kaltim Post','2':'Kompas','3':'Tribun Kaltim'}
},
A2: {
title: 'Hari',
width: '10%',
options: {'1':'Senin','2':'Selasa','3':'Rabu','4':'Kamis','5':'Jumat','6':'Sabtu','7':'Minggu'}
},
A3: {
title: 'Tanggal',
width: '15%',
type: 'date',
displayFormat: 'yy-mm-dd'
},
A4: {
title: 'Bulan',
width: '10%',
options: {'1':'Januari','2':'Februari','3':'Maret','4':'April','5':'Mei','6':'Juni','7':'Juli','8':'Agustus','9':'September','10':'Oktober','11':'November','12':'Desember'}
},
A5: {
title: 'Tahun',
width: '10%',
options: {'':'','2013':'2013','2012':'2012','2011':'2011','2010':'2010','2009':'2009','2014':'2014','2015':'2015','2016':'2016'} },
A6: {
title: 'Judul',
type: 'textarea',
width: '40%',
},
A7: {
title: 'Ringkasan',
type: 'textarea',
list: false
},
A8: {
title: 'Klasifikasi',
type: 'varchar',
width: '10%'
},

RecordDate: {
title: 'Record date',
create: false,
edit: false,
list: false
}
}
});

//Load person list from server
$('#KoranTableContainer').jtable('load');
});

[removed]

</body>
</html>

*sourcecode simpan data

<?php

try
{
//Open database connection
$con = mysql_connect("localhost","root","samarinda");
mysql_select_db("jtabletestdb", $con);

//Getting records (listAction)
if($_GET["action"] == "list")
{
//Get record count
$result = mysql_query("SELECT COUNT(*) AS RecordCount FROM klipingdb;");
$row = mysql_fetch_array($result);
$recordCount = $row['RecordCount'];

//Get records from database
$result = mysql_query("SELECT * FROM klipingdb ORDER BY " . $_GET["jtSorting"] . " LIMIT " . $_GET["jtStartIndex"] . "," . $_GET["jtPageSize"] . ";");

//Add all records to an array
$rows = array();
while($row = mysql_fetch_array($result))
{
$rows[] = $row;
}

//Return result to jTable
$jTableResult = array();
$jTableResult['Result'] = "OK";
$jTableResult['TotalRecordCount'] = $recordCount;
$jTableResult['Records'] = $rows;
print json_encode($jTableResult);
}
//Creating a new record (createAction)
else if($_GET["action"] == "create")
{
//Insert record into database
$result = mysql_query("INSERT INTO Klipingdb(A1, A2, A3, A4, A5, A6, A7, A8, RecordDate) VALUES(" . $_POST["A1"] . ", " . $_POST["A2"] . ", '" . $_POST["A3"] . "', " . $_POST["A4"] . ", " . $_POST["A4"] . ", '" . $_POST["A6"] . "', '" . $_POST["A7"] . "', '" . $_POST["A8"] . "', now());");

//Get last inserted record (to return to jTable)
$result = mysql_query("SELECT * FROM Klipingdb WHERE ID = LAST_INSERT_ID();");
$row = mysql_fetch_array($result);

//Return result to jTable
$jTableResult = array();
$jTableResult['Result'] = "OK";
$jTableResult['Record'] = $row;
print json_encode($jTableResult);
}
//Updating a record (updateAction)
else if($_GET["action"] == "update")
{
//Update record in database
$result = mysql_query("UPDATE Klipingdb SET A1 = " . $_POST["A1"] . ", A2 = " . $_POST["A2"] . ", A3 = '" . $_POST["A3"] . "', A4 = " . $_POST["A4"] . ", A5 = " . $_POST["A5"] . ", A6 = '" . $_POST["A6"] . "', A7 = '" . $_POST["A7"] . "', A8 = '" . $_POST["A8"] . "' WHERE ID = " . $_POST["ID"] . ";");

//Return result to jTable
$jTableResult = array();
$jTableResult['Result'] = "OK";
print json_encode($jTableResult);
}
//Deleting a record (deleteAction)
else if($_GET["action"] == "delete")
{
//Delete from database
$result = mysql_query("DELETE FROM Klipingdb WHERE ID = " . $_POST["ID"] . ";");

//Return result to jTable
$jTableResult = array();
$jTableResult['Result'] = "OK";
print json_encode($jTableResult);
}

//Close database connection
mysql_close($con);

}
catch(Exception $ex)
{
//Return error message
$jTableResult = array();
$jTableResult['Result'] = "ERROR";
$jTableResult['Message'] = $ex->getMessage();
print json_encode($jTableResult);
}

?>


Tanya PhpTanya PhpTanya Php
emoticon-Sorry

tanya cara baca koding php

halo agan agan
ane mau tanya ini bacanya gmna ya
$act=(empty($_POST['batas']))? 10:$_POST['batas']

terutama tanda ? dan : di situ gunanya untuk apa ya
Quote:Original Posted By yogaardi88
halo agan agan
ane mau tanya ini bacanya gmna ya
$act=(empty($_POST['batas']))? 10:$_POST['batas']

terutama tanda ? dan : di situ gunanya untuk apa ya

? : itu mirip if else.
PHP Code:
if (empty($_POST['batas']))
    
$act 10;
else
    
$act $_POST['batas'];