No, I'm not scared, but it should be ok with you. I'll paste it. if it is too long, you can tell me, i will edit the thread and attach file. Okay...here we go...
As i said, this creates a MySQL table w/ ID/Address/Notes columns. You can upload, edit and delete info. One known problem is that when editing the adress, you leave it blank, it would not perform the update, however, if you put a space only, it would empty the data and then everything messes up. Obviously it considers " " to be the same as "". Also a question: is "" and NULL the same thing?
I looked at the library and liked Elmseeker's way of outputing things, so...the file is called noHTML0.php
tank you guys!
PHP Code:
<html>
<head>
<title>Hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="default.css" />
</head>
<body text="#CCCCCC" bgcolor="e2e2e2" leftmargin="0" topmargin="0" bottommargin="0" marginwidth="0" marginheight="0" >
<?php
$obj = new do_form();
/////////////// GLOBALS/////////////////////////////
////
// defined in the function globals_defined()
$g = "get";
$p = "post";
$this_file_name = "noHTML0.php";
////
////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
///// MYDQL //
//////////
//////
//
# CONNECTION
$host = "localhost";
$user = "";
$pass = "";
$database_name = "buildings_database";
$table_name = "table_name";
$link = mysql_connect ($host, $user, $pass);
#if($link )
#echo "Establishing Connection... V<br>";
#else
#echo "Establishing Connection... X<br>".mysql_error();
# DB CREATION
$creating_db_check = mysql_query("CREATE DATABASE $database_name");
#if($creating_db_check)
#echo "Creating Database...V<br>";
#else
#echo "Creating Database...X<br>".mysql_error();
# DB SELECTION
$selecting_db_check = mysql_select_db ($database_name);
#if ( $selecting_db_check)
#echo "Selecting Database... V<br>";
#else
#echo "Selecting Database... X<br>".mysql_error();
# TABLE CREATION
$create_table_check = mysql_query( "CREATE TABLE $table_name (
id INT NOT NULL AUTO_INCREMENT,
Address VARCHAR (40) UNIQUE NOT NULL,
Notes VARCHAR (40),
PRIMARY KEY (id)
)");
#if ($create_table_check)
#echo "Creating Table... V<BR>";
#else
#echo "Creating Table... X<BR>".mysql_error()."<br>";
# VARIABLES
$address_upload = $_GET['address_upload_get'];
echo "<br>address_upload: ".$address_upload;
$notes_upload = $_GET['notes_upload_get'];
echo "<br>notes_upload: ".$notes_upload;
$upload_clicked = $_GET['upload_clicked_get'];
echo "<br>upload_clicked:".$upload_clicked;
$address_select = $_GET['address_select_get'];
echo "<br>address_select: ".$address_select;
$result = mysql_query ("SELECT * FROM $table_name WHERE Address = '$address_select'");
$result = mysql_fetch_array ($result);
$notes_select = $result['Notes'];
echo "<br>notes_select: ".$notes_select;
$result = mysql_query ("SELECT * FROM $table_name WHERE Address = '$address_select'");
$result = mysql_fetch_array ($result);
$id_select = $result['id'];
echo "<br>id_select: ".$id_select;
$address_edit = $_GET['address_edit_get'];
echo "<br>address_edit: ".$address_edit;
$notes_edit = $_GET['notes_edit_get'];
echo "<br>notes_edit: ".$notes_edit;
$hidden_transfer_id = $_GET['hidden_transfer_id_get'];
echo "<br>hidden_transfer_id: ".$hidden_transfer_id;
$select_edit_clicked = $_GET['select_edit_clicked_get'];
echo "<br>select_edit_clicked: ".$select_edit_clicked;
$update_edit_clicked = $_GET['update_edit_clicked_get'];
echo "<br>update_edit_clicked: ".$update_edit_clicked;
$address_delete = $_GET['address_delete_get'];
echo "<BR>address_delete: ".$address_delete;
#$select_all_query = mysql_query ("SELECT * FROM $table_name");
#print_r displays everything for a $, array, object;
# mysql_fetch_row returns an array with elements all the cells from this row
# mysql_fetch_array returns:1. assiciative array with key=number of cell value=cell content
# 2. associative arrya with key=column name value=cell content
# mysql_fetch_object returns an object for which properties=comun names value = cell content
# mysql_fetch_field returns an object with all the properties of a column.
/////////////// INSERTION////////////////////////////
////
if (($idea_edit == null)&&($update_edit_clicked!=0)){
$status_upload = "Pls specify address";
$show_status_upload = 1;
}
if ($address_upload!=null){
$check_insert = mysql_query( "INSERT INTO $table_name ( Address, Notes) VALUES( '$address_upload', '$notes_upload')", $link );
$show_status_upload = 1;
if ( $check_insert){
$status_upload = "Inserting '$address_upload' Successful";
$upload_successful = 1;
}else{
$status_upload = "You already have this one";
}
}
////
////////////////////////////////////////////////////
/////////////// EDITING ////////////////////////////
////
if (($address_edit == null)&&($update_edit_clicked!=0)){
$update_edit_clicked = 1;
$status_edit = "You cannot have EMPTY value for Adres! You can delete it from<br>|<BR>|<BR>|<BR>|<BR>\/";
}else{
if (($hidden_transfer_id!=0)&&($address_edit != null)){
$update_edit_clicked = 1;
$result = mysql_query ("UPDATE $table_name SET Notes = '$notes_edit' WHERE id = '$hidden_transfer_id' ");
if ($result) $status_edit_1 = 1;
$result= mysql_query ("UPDATE $table_name SET Address = '$address_edit' WHERE id = '$hidden_transfer_id' ");
if ($result) $status_edit_2 = 1;
if (($status_edit_1==1)&&($status_edit_2==1)) $status_edit = "Updating \"".$address_edit."\" is successful.";
else $status_edit = "Updating \"".$address_edit."\" failed.";
}elseif (($hidden_transfer_id!=0)&&($address_edit == null)){
$update_edit_clicked =1;
$status_edit = "You cant't leave the Address blank empty. Not updated.";
}
} ////
////////////////////////////////////////////////////
if ($address_delete!=null){
$result = mysql_query ("DELETE FROM $table_name WHERE Address = '$address_delete' ");
echo "<BR>ADDRESS_DELETE: ".$address_delete;
if ($result)
$status_delete = "Deleted successfully";
else
$status_delete = "Delete Failed";
$show_status_delete = 1;
}
//
//////
//////////
///// MYSQL //
//////////////////////////////////////////////////////////////////////////////////////
$obj->ot();
$obj->orow();
$obj->odv("top");
//////////////////////////////////////////////////////////////////////////////////////
/// UPLAODER /
//////////
//////
//
$obj->obt();
$obj->margin_up();
$obj->blh();
$obj->title("Uploader");
$obj->blh();
$obj->orow();
$obj->bc();
$obj->od();
$obj->otwa(760,"left");
$obj->orow();
$obj->oform($this_file_name,$g);
$obj->odw(310);
$obj->otw(300);
$obj->orow();
$obj->odw(150);
$obj->output("Adres of the Estate: ");
$obj->cd();
$obj->odw(150);
$obj->input("address_upload_get","");
$obj->cd();
$obj->crow();
$obj->orow();
$obj->odw(150);
$obj->output("Additional Notes: ");
$obj->cd();
$obj->odw(150);
$obj->input("notes_upload_get","");
$obj->cd();
$obj->crow();
$obj->ct();
$obj->cd();
$obj->od();
$obj->submit("Upload Estate");
$obj->cd();
$obj->od();
$obj->otwa(250,"right");
$obj->orow();
$obj->odwa(90,"left");
$obj->output("View ");
$obj->cd();
$obj->odwav(90,"left", "middle");
$obj->olink("view_all.php","");
$obj->output("- all the buildings and lots");
$obj->clink();
$obj->cd();
$obj->crow();
if ($upload_successful==1){
$obj->orow();
$obj->od();
$obj->cd();
$obj->oda("left");
$obj->olink("view_one.php?", "");
$obj->output("- only $address_upload");
$obj->clink();
$obj->cd();
$obj->crow();
}
$obj->ct();
$obj->cd();
$obj->cform();
$obj->crow();
$obj->ct();
$obj->cd();
$obj->bc();
$obj->crow();
$obj->blh();
if (isset($show_status_upload)){
$obj->orow();
$obj->bc();
$obj->od();
$obj->ocss("orange");
$obj->output("$status_upload");
$obj->ocss("orange");
$obj->cd();
$obj->bc();
$obj->crow();
$obj->blh();
}
$obj->ct();
//
//////
//////////
/// UPLOADER /
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//// EDITOR //
//////////
//////
//
if (1==1){
$obj->obt();
$obj->margin_up();
$obj->blh();
$obj->title("Editor");
$obj->blh();
$obj->orow();
$obj->bc();
$obj->od();
$obj->ota("left");
$obj->orow();
$obj->oform($this_file_name,$g);
$obj->oda("left");
$obj->oselect("address_select_get");
$select_all_query = mysql_query ("SELECT * FROM $table_name");
while ($temp = mysql_fetch_array($select_all_query)){
if ($address_select==$temp[Address]) $obj->options("$temp[Address]");
else $obj->option("$temp[Address]");
}
$obj->cselect();
$obj->cd();
$obj->oda("left");
$obj->submit("Edit Selection");
$obj->hidden("select_edit_clicked_get","clicked");
$obj->cd();
$obj->cform();
if ($address_select!=null){
$obj->oform($this_file_name,$g);
$obj->oda("left");
$obj->ot();
$obj->orow();
$obj->od();
$obj->input("address_edit_get","$address_select");
$obj->cd();
$obj->crow();
$obj->orow();
$obj->od();
$obj->input("notes_edit_get","$notes_select");
$obj->hidden("hidden_transfer_id_get", "$id_select");
$obj->hidden("update_edit_clicked_get", "clicked");
$obj->cd();
$obj->crow();
$obj->ct();
$obj->cd();
$obj->oda("left");
$obj->submit("Update Selection");
$obj->cd();
$obj->cform();
}
$obj->crow();
$obj->ct();
$obj->cd();
$obj->bc();
$obj->crow();
$obj->blh();
if ($update_edit_clicked==1){
$obj->orow();
$obj->bc();
$obj->od();
$obj->ocss("orange");
$obj->output("$status_edit");
$obj->ccss();
$obj->cd();
$obj->bc();
$obj->crow();
$obj->blh();
}
$obj->ct();
}
//
//////
//////////
//// EDITOR //
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
/// DELETER //
//////////
//////
//
if (1==1){
$obj->obt();
$obj->margin_up();
$obj->blh();
$obj->title("Deleter");
$obj->blh();
$obj->orow();
$obj->bc();
$obj->od();
$obj->ota("left");
$obj->orow();
$obj->oform($this_file_name,$g);
$obj->oda("left");
$obj->oselect("address_delete_get");
$select_all_query = mysql_query ("SELECT * FROM $table_name");
while ($temp = mysql_fetch_array($select_all_query)){
$obj->option("$temp[Address]");
}
$obj->cselect();
$obj->cd();
$obj->oda("left");
$obj->submit("Delete Selection");
$obj->cd();
//tazi kletka mozhe da se mahne...tq e za majtap.
//Molq ne se smej. tq e samo kletka!
$obj->cform();
$obj->crow();
$obj->ct();
$obj->cd();
$obj->bc();
$obj->crow();
$obj->blh();
if ($show_status_delete==1){
$obj->orow();
$obj->bc();
$obj->od();
$obj->ocss("orange");
$obj->output("$status_delete");
$obj->ccss();
$obj->cd();
$obj->bc();
$obj->crow();
$obj->blh();
}
$obj->ct();
}
//
//////
//////////
/// DELETER //
//////////////////////////////////////////////////////////////////////////////////
$obj->cd();
$obj->od();
echo "\n<table border = \"1\">";
$result = mysql_query ("SELECT * FROM $table_name");
while ($temp2 = mysql_fetch_row($result)){
echo "\n\t<tr>";
foreach($temp2 as $temp3){
echo "\n\t\t<td>$temp3<br></td>";}
echo "\n\t</tr>";
}
echo "\n</table>";
$obj->cd();
$obj->crow();
$obj->ct();
class do_form {
//////////////////////////////////////////////////////////////////////////////////
// TABLE FUNCTIONS
//////////
//////
//
function ot(){ // Open Table
echo <<<PEPE
<table bgcolor="#e2e2e2" border="0" cellpadding="0" cellspacing="0" align="center">
PEPE;
}
function ota($align){ // Open Table w/ ALIGN
echo <<<PEPE
<table bgcolor="#e2e2e2" border="0" cellpadding="0" cellspacing="0" align="$align">
PEPE;
}
function otw($width_table){ // Open Table w/ WIDTH
echo <<<PEPE
<table bgcolor="#e2e2e2" border="0" width="$width_table" cellpadding="0" cellspacing="0" marginleft="0" align="center">
PEPE;
}
function otwa($width, $align){ // Open Table w/ ALIGN
echo <<<PEPE
<table bgcolor="#e2e2e2" border="0" width="$width" cellpadding="0" cellspacing="0" align="$align">
PEPE;
}
function obt(){ //Open Big Table
echo <<<PEPE
<table bgcolor="#e2e2e2" border="0" cellpadding="0" cellspacing="0" width="777" align="center">
PEPE;
}
function ct(){ // Close Table
echo <<<PEPE
</table>
PEPE;
}
function margin_up(){ //The one invisible row, that makes the table go down
echo <<<PEPE
<tr>
<td colspan="3" height="30"></td>
</tr>
PEPE;
}
function blh(){ //blh = Black Line horizontal height=1
echo <<<PEPE
<tr>
<td bgcolor="#000000" width="1"></td>
<td bgcolor="#000000" height="1"></td>
<td bgcolor="#000000" width="1"></td>
</tr>
PEPE;
}
function title($title_of_table){ // Row that contains the title
echo <<<PEPE
<tr>
<td bgcolor="#000000" width="1"></td>
<td bgcolor="#CCCCCC" height="15" align="center" class="orangeThickSmallCaps">$title_of_table</td>
<td bgcolor="#000000" width="1"></td>
</tr>
PEPE;
}
function orow(){ // Opening Row
echo <<<PEPE
<tr>
PEPE;
}
function crow(){ // Closing Row
echo <<<PEPE
</tr>
PEPE;
}
function bc(){ //Black Cell
echo <<<PEPE
<td bgcolor="#000000" width="1"></td>
PEPE;
}
function od(){ // Open Cell
echo <<<PEPE
<td align="center">
PEPE;
}
function oda($align){ // Open Cell
echo <<<PEPE
<td align="$align">
PEPE;
}
function odw($width_cell){ //Open Cell w/ WIDTH
echo <<<PEPE
<td align="center" width="$width_cell">
PEPE;
}
function odwa($width_cell, $align){ //Open Cell w/ WIDTH ALIGN
echo <<<PEPE
<td align="$align" width="$width_cell">
PEPE;
}
function odwv($width_cell, $v_align){ //Open Cell w/ WIDTH VALIGN
echo <<<PEPE
<td align="center" width="$width_cell" valign="$v_align">
PEPE;
}
function odwav($width_cell, $align, $v_align){ // Open Cell w/ WIDTH ALIGN VALIGN
echo <<<PEPE
<td align="$align" width="width_cell" valign="$v_align">
PEPE;
}
function odv($v_align){
echo <<<PEPE
<td valign="$v_align">
PEPE;
}
function cd(){ // Close Cell
echo <<<PEPE
</td>
PEPE;
}
//
//////
//////////
/// TABLE DUNCTIONS
//////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
///// FORM //
/////////
/////
function oform($file, $method){ // Form Open
echo <<<PEPE
<form action="$file" method="$method">
PEPE;
}
function cform(){ // Form Close
echo <<<PEPE
</form>
PEPE;
}
function submit($value){ // Form Submit button
echo <<<PEPE
<input type="submit" value="$value" >
PEPE;
}
function input($name,$value){ //Form Input Text
echo <<<PEPE
<input name="$name" value="$value">
PEPE;
}
function oselect($name){ // Open Select Form
echo <<<PEPE
<select name="$name">
PEPE;
}
function option($option){ // Put a Selection
echo <<<PEPE
<option>$option
PEPE;
}
function options($option){
echo <<<PEPE
<option selected>$option
PEPE;
}
function cselect(){ // Close Select Form
echo <<<PEPE
</select>
PEPE;
}
function hidden($name,$value){
echo <<<PEPE
<input type="hidden" name="$name" value="$value">
PEPE;
}
///
///////
/// FORM //
///////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
///// MISC //
/////////
/////
function globals_defined(){ // GLOBALS
global $this_file_name;
global $g;
global $p;
}
function olink($link, $class){ // OPEN LINK
echo <<<PEPE
<a href="$link" class="$class">
PEPE;
}
function clink(){ // CLOSE LINK
echo <<<PEPE
</a>
PEPE;
}
function brejk(){ // <BR>
echo<<<PEPE
<BR>
PEPE;
}
function output($the_put){ //Echo stuff
echo <<<PEPE
$the_put
PEPE;
}
function ocss($class){
echo <<<PEPE
<div class="$class">
PEPE;
}
function ccss(){
echo <<<PEPE
</div>
PEPE;
}
///
///////
/// MISC //
///////////////////////////////////////////////////////////////////////////
}
?>
</body>
</html>
|