You are here: [newbie] Keeping it all in one page? « PHP Programming Language « IT news, forums, messages
[newbie] Keeping it all in one page?

Posted by Gilles Ganault on 01/29/08 18:30

Hello

Out of curiosity, is this an acceptable way to build a small,
all-in-one script to create/update/list/delete records in a table?

This is a bit of pseudo-code (eg. don't know if "switch" exists in
PHP, nor if it trickles down in the absence of "break"), but you get
the idea:

============
<?php

$base = "mydb";

switch $status {
case 'update'
//fetch existing record, and go on to next case
$query = "SELECT ... WHERE ..."

case 'create' || 'update'
//Show form to create/modify an existing record
echo "<form method=post>";
echo "<input type=hidden name=status value=\"save\">";
echo "Name <input type=\"text\" name=\"txtField\"><p>";
echo "<input type=\"submit\" name=\"create\"
value=\"Create\"></p>";
echo "</form>";

case 'create_update'
//Save newly-created record
$query = "INSERT..."

case 'create_save'
//Save modified, existing record
$query = "UPDATE..."

case default
//List records, and include a "Modify/delete" button
$query = "SELECT..."
}
============

Thank you.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация