Best way to make table data editable?
Posted: Wed Apr 20, 2016 4:10 am
Hi,
I know its 5 years later.
I used your example now i have this:
Offcourse i have configured my database details.
But my problem is when i click submit it does not save the changed details.
can somebody please help me ?
kind regards,
Sterrek
I know its 5 years later.
I used your example now i have this:
Code: Select all
<?php
$users = array();
// Setting up the connection
$connection = array(
'type' => 'sql',
'host' => 'localhost',
'database' => 'database',
'user' => 'user',
'password' => 'pass'
);
$db = new mysqli($connection['host'],$connection['user'], $connection['password'], $connection['database']);
if($db->connect_errno > 0){
die('Unable to connect to database [' . $db->connect_error . ']');
}
$query = 'SELECT title, description, user_impact, datetime, FROM ideas';
$result = $db->query($query);
if(!$result){
die('There was an error running the query [' . $db->error . ']');
}
$users = $result->fetch_assoc();
?>
<script type="text/javascript">
var designments = <?= json_encode($designments) ?>;
</script>
<section class="fl w1200">
<p class="clearfix"><span class="bg-white ff-b orange f28 title-1 fl shadow">Ideas Editor</span></p>
<div id="admin-menu">
<span> <a href="url" id="users-btn" class="fl bg-white black ff-mob f16 shadow ttu" >Users</a> </span>
<span> <a href="url" id="Designments-btn" class="fl bg-white black ff-mob f16 shadow ttu ">Designments Editor</a> </span>
<span> <a href="url" id="Ideas-btn" class="fl bg-white black ff-mob f16 shadow ttu">Ideas Editor</a> </span>
</div>
<div id="users" class="admin-panel shadow p15">
<div class="w940 masonry">
<div id="users" class="admin-panel shadow p15">
<div class="w940 masonry">
<?php if(is_admin()){ ?>
<div class="filter w460 stamp shadow bg-white" style="margin-bottom: 10px;">
<span class="ttu orange ff-b">User filter:</span>
<select id="name-filter">
<option value="0">Show all</option>
<option value="0">designers in designment</option>
<option value="0">idea uploaders in designment</option>
<option value="0">inspiration uploaders in designment</option>
</select>
</div>
<?php } ?>
<table>
<thead>
<tr>
<th>
Title
</th>
<th>
Description
</th>
<th>
user impact
<th>
Datetime
</th>
</tr>
<table>
<?php while ($row = $result->fetch_object()) { ?>
<ul> <tr><input type="text" name="title" value="<?php echo $row->title; ?>" /></tr> </ul>
<tr><input type="text" name="description" value="<?php echo $row->description; ?>" /></tr>
<tr><input type="text" name="user_impact" value="<?php echo $row->user_impact; ?>" /></tr>
<tr><input type="text" name="datetime" value="<?php echo $row->datetime; ?>" /></tr>
<?php } ?>
<input type="submit" value="submit changes"/>
</table>
</form>
</div>
</script>But my problem is when i click submit it does not save the changed details.
can somebody please help me ?
kind regards,
Sterrek