I am only beginner at this. I don't understand this fully, half of it was given to me and other half was my team writing it out. I can't work out how to create a form to edit a table. There is people.php file. Thats the file I want to put in edit form. Search and Insert form is working fine. In different folder there called crud_single_table. In that folder there are code for update, insert, confirm_update, etc. No edit code in there yet cos I don't know excalty what code put in there.
In my people.php
<?php
WHERE name!='fluffy' ORDER BY name";
$header = "PEOPLE";
$table = "people";
$query = "Select * from ".$table." where true ";
$value = '';
if (isset($_GET['value']))
{
$value = $_GET['value'];
}
$field = '';
if (isset($_GET['field']))
{
$field = $_GET['field'];
}
$mode = $_GET['mode'];
if ($mode == '')
{
$mode = 'search';
}
$result = mysql_query ($query) or die("Query failed");
$rows = mysql_num_rows ($result);
$columns = mysql_num_fields($result);
?>
<script>
function refresh()
{
// some code here
}
function insert_new()
{
var sURL = unescape(window.location.pathname);
//alert (sURL);
window.location.href = sURL+"?here=<?php echo $here ?>&mode=insert";
}
function update_data(pino,gino)
{
var sURL = unescape(window.location.pathname);
//alert (sURL);
window.location.href = sURL+"?here=<?php echo $here ?>&mode=update&field="+pino+"&value="+gino;
//alert (sURL+"?here=<?php echo $here ?>&mode=update&field="+pino+"&value="+gino);
}
</script>
<div id=manage_content>
<input type=button id=button1 value='Refresh' onclick="javascript:refresh();">
<input type=button id=button1 value='Search table' onclick="javascript:viewall();">
<input type=button id=button1 value='Insert new' onclick="javascript:insert_new();">
</div>
</div>
<div id=manage_form>
<?php
$form_as_html = "<B>FIELDS</B> "."MODE = ".$mode." <P><table id='table2' width=100%>";
if ($mode == 'search')
{
include("crud_single_table/search.php");
echo $form_as_html;
}
if ($mode == 'insert')
{
include("crud_single_table/insert.php");
echo $form_as_html ;
}
if ($mode == 'confirm_insert')
{
include("crud_single_table/confirm_insert.php");
//echo $form_as_html;
}
if ($mode == 'update')
{
include("crud_single_table/update.php");
echo $form_as_html ;
}
if ($mode == 'confirm_update')
{
include("crud_single_table/confirm_update.php");
//echo $form_as_html;
}
if ($mode == 'confirm_search')
{
include("crud_single_table/search.php");
echo $form_as_html;
}
?>
</div>
<div id=list_content>
<?php
include("crud_single_table/show_select.php");
echo ($result_as_html);
?>
</div>
<?php
mysql_close();
?>