{"id":83,"date":"2007-10-17T13:06:04","date_gmt":"2007-10-17T11:06:04","guid":{"rendered":"http:\/\/www.hermione.de\/blog\/?p=83"},"modified":"2007-10-26T12:29:03","modified_gmt":"2007-10-26T10:29:03","slug":"phormation","status":"publish","type":"post","link":"http:\/\/blog.hermione.de\/?p=83","title":{"rendered":"phormation"},"content":{"rendered":"<p>php-Framework fuer html Formulare mit datenbank backend &#8230;<br \/>\n<!--more--><\/p>\n<h4>Phormation set up<\/h4>\n<p>Installation der Files in z.B. \/usr\/lib\/phormation.<\/p>\n<table class=\"rosa\">\n<tr>\n<td><strong>global.php<\/strong><\/p>\n<pre><code class=\"ex\">&lt; ?\r\nDEFINE( \"PHORMATIONDIR\", \"\/usr\/lib\/phormation\" );\r\nDEFINE( \"PHORMATIONIMAGEDIR\", \"\/var\/www\/phormationimage\" );\r\n$DB = \"mysql\";\r\n$DATABASE = \"people\";\r\n?&gt;<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<h4>Datenbank set up<\/h4>\n<p>Datenbank und Tabelle erzeugen mysql -p &lt; db.sql<\/p>\n<table class=\"rosa\">\n<tr>\n<td><strong>db.sql<\/strong><\/p>\n<pre><code class=\"ex\">\r\nCREATE DATABASE IF NOT EXISTS people;\r\nuse  people;\r\nDROP TABLE names;\r\nCREATE TABLE names (\r\n   id     int auto_increment not null,\r\n   firstname   varchar(50),\r\n   lastname    varchar(50),\r\n   primary key( id )\r\n   );<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<p>Die Datenbankverbindung muss in der Variablen <strong>$conn<\/strong> gespeichert werden:<\/p>\n<table class=\"rosa\">\n<tr>\n<td><strong>dbconnect.php<\/strong><\/p>\n<pre><code class=\"ex\">&lt; ?\r\n  $conn = mysql_connect(\"host\", \"name\", \"passwort\");\r\n  if( !$conn ) {\r\n    echo \"Couldn't connect to database!\";\r\n  }\r\n $dbs = mysql_select_db($DATABASE,$conn);\r\n  if( !$dbs ) {\r\n    echo \"Couldn't connect to database $DATABASE !\";\r\n  }\r\n? &gt;<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<h4>Index<\/h4>\n<table class=\"rosa\">\n<tr>\n<td>\n<pre><code class=\"ex\">&lt; ?\r\ninclude_once(\"global.php\");\r\ninclude_once(\"dbconnect.php\");\r\n<strong>include_once( PHORMATIONDIR . \"\/displaytable.php\");<\/strong>\r\n\r\n<strong>\/\/ html vor der Tabelle<\/strong>\r\nfunction html_before_table() {\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"styles.css\"&gt;\r\n&lt;title&gt;Tolles Formular&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1&gt;Tabellet&lt;\/h1&gt;\r\n}\r\n\r\n<strong>\/\/ html nach der Tabelle<\/strong>\r\nfunction html_after_table() {\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n}\r\n\r\n<strong>\/\/ Felder<\/strong>\r\n$fields[] = \"firstname\"; $name[] = \"Vorname\";\r\n$fields[] = \"lastname\"; $name[] = \"Nachname\";\r\n\r\n<strong>\/\/ notwendige Parameter<\/strong>\r\n$params[\"query\"] = \"SELECT * FROM $DATABASE.names\";\r\n$param[\"defaultsort\"] = \"lastname\";\r\n$param[\"editlink\"] = \"editButtonLink.php\";\r\n$param[\"newlink\"] = \"newButtonLink.php\";\r\n$param[\"delquery\"] = \"DELETE FROM $DATEBASE.names WHERE id= \";\r\n$param[\"key\"] = \"id\";\r\n\r\n<strong>\/\/ Tabelle<\/strong>\r\ntable_index( $fields, $names, $params );\r\n? &gt;<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<h4>Formular<\/h4>\n<table class=\"rosa\">\n<tr>\n<td>\n<pre><code class=\"ex\">&lt; ?\r\ninclude_once(\"global.php\");\r\ninclude_once(\"dbconnect.php\");\r\ninclude_once( PHORMATIONDIR . \"\/form.php\");\r\n\r\n<strong>\/\/ html vor dem Formular<\/strong>\r\nfunction html_before_form() {\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"styles.css\"&gt;\r\n&lt;title&gt;Tolles Formular&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1&gt;Formular&lt;\/h1&gt;\r\n}\r\n\r\n<strong>\/\/ html nach dem Formular<\/strong>\r\nfunction html_after_form() {\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n}\r\n\r\n<strong>\/\/ Formularfelder<\/strong>\r\n$fields[] = \"firstname\";\r\n$name[] = \"Vorname\";\r\n$types[]  = \"type=text&amp;width=22&amp;length=40&amp;required=1\";\r\n\r\n$fields[] = \"lastname\";\r\n$name[] = \"Nachname\";\r\n$types[]  = \"type=text&amp;width=22&amp;length=40&amp;required=1\";\r\n\r\n<strong>\/\/ Formular<\/strong>\r\nform_main( \"people.names\", \"id\", $fields, $names, $types, $record_id, $url, $opts );\r\n? &gt;<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>php-Framework fuer html Formulare mit datenbank backend &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.hermione.de\/index.php?rest_route=\/wp\/v2\/posts\/83"}],"collection":[{"href":"http:\/\/blog.hermione.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.hermione.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.hermione.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.hermione.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=83"}],"version-history":[{"count":0,"href":"http:\/\/blog.hermione.de\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.hermione.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.hermione.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.hermione.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}