So i managed to make my "first" this kind of script.. based on archez ( he gave me this do == system )
But there is a update error while i want to insert values in the database error:
echo 'There was an error during the updating process!';
But there is a update error while i want to insert values in the database error:
echo 'There was an error during the updating process!';
PHP:
<?PHP
$array = array(
'1' => 'Topic',
'2' => 'Author',
'3' => 'Image_Id',
'4' => 'Hide_News');
if($_REQUEST['do'] == 'index')
{ ?>
<div class="column" id="right"></div>
<div id="tab2" class="tab_content">
<div class="portlet">
<div class="portlet-header fixed"><img src="images/icons/user.gif" width="16" height="16" alt="" />Item details</div>
<div class="portlet-content nopadding">
<form action="#" method="post"> <table cellspacing="0" cellpadding="0" width="100%" summary="" id="box-table-a">
<table cellspacing="0" cellpadding="0" width="100%" summary="" id="box-table-a">
<thead>
<tr>
<th width="102" scope="col">#</th>
<th width="136" scope="col">Title</th>
<th width="136" scope="col">Author</th>
<th width="136" scope="col">image_id</th>
<th width="102" scope="col">hide_news</th>
<th width="102" scope="col">text</th>
</tr>
</thead>
<tbody>
<?PHP
$i=1;
$data = $mysqli->query("SELECT * FROM `z_news_big`");
while($item = $data->fetch_array()){
echo "<tr><td>".$i."</td>";
echo "<td>".$item['topic']."</td>";
echo "<td>".$item['author']."</td>";
echo "<td>".$item['image_id']."</td>";
echo "<td>".$item['hide_news']."</td>";
echo "<td><textarea class='tinymce'>".$item['text']."</textarea></td></tr>";
$i++;
}
unset ($data);
?>
</tbody>
</table>
</form>
</div>
</div>
</div>
<?PHP
echo '<form action="?page=news&do=update" method="post">';
$i=1;
$data = $mysqli->query("SELECT * FROM `z_news_big`");
echo '<table>';
while($a = $data->fetch_array()){
echo '<tr><td width="20%">'.$array[1].' :<input type="text" name="'.$a['topic'].'" value="'.$a['topic'].'"></td>';
echo '<td>'.$array[2].' : <input type="text" name="'.$a['author'].'" value="'.$a['author'].'"></td>';
echo '<td>'.$array[3].' : <input type="text" name="'.$a['image_id'].'" value="'.$a['image_id'].'"></td>';
echo '<td>'.$array[4].' : <input type="text" name="'.$a['hide_news'].'" value="'.$a['hide_news'].'"></td>';
//echo ''.$a['text'].' : <textarea name="'.$a['text'].'>'.$item['text'].'</textarea>';
}
echo '<tr><td><input type="submit" value="Update" /></td><td><input type="reset" value="Clear" /></td></tr>';
unset ($data);
echo '</tr></table>';
echo '</form>';
}
if($_REQUEST['do'] == 'update')
{
if(!$_POST)
{
echo 'error';
}
else
{
$array1 = array(
'1' => 'topic',
'2' => 'author',
'3' => 'image_id',
'4' => 'hide_news');
$query .= 'UPDATE `z_news_big` SET ';
foreach($array1 as $c => $d)
{
$query .= '`'.strip_tags($d).'` = "'.strip_tags($_POST[$d]).'", ';
}
$execute = $mysqli->query($query);
if($execute)
{
echo 'Done!';
}
else
{
echo 'There was an error during the updating process!';
}
}
}
?>