Best way to make table data editable?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sterrek
Forum Newbie
Posts: 1
Joined: Wed Apr 20, 2016 4:01 am

Best way to make table data editable?

Post by sterrek »

Hi,

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>
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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Best way to make table data editable?

Post by requinix »

(split from Best way to make table data editable?)

Don't bump threads for your own questions - make new ones.

I don't see an opening <form>, and there's no PHP code that supports anything happening when the form is submitted. Have you not written that part yet?
Post Reply