eisagogi stoixeion stin basi dedomenon se trito pinaka

Σε αυτή την περιοχή μπορείτε να βρείτε ή να αναζητήσετε πληροφορίες σχετικές με την PHP

Συντονιστές: WebDev Moderators, Super-Moderators, PHP Moderators

Απάντηση
kingbill
Δημοσιεύσεις: 244
Εγγραφή: 19 Νοέμ 2005 15:06

eisagogi stoixeion stin basi dedomenon se trito pinaka

Δημοσίευση από kingbill » 12 Δεκ 2005 22:14

exo 3 pinakes foitites tmhmata kai foitites_tmhmata

1) foitites (onoma , eponumo, aem)

2) tmhmata (kodikostmhmatos, kodikosergasthriou onomatmhmatos)

3) fotites_tmhmata (kodikostmhmatos, aem, proteraiotita )

o pinakas tmhmata einai eksrtimeni ontotita tou ergasthriou

to problima einai pos tha ekxorisso times sto pinaka foitites_tmhmata
exo kanei mia forma pou o foititis grafei to aem tou kai tin proteraiotita tou
kai dialegei ta tmhmata diladi to ergasthrio programmatismos exei 4 tmhmata
E!, E2 , E3, E4 o foititis tha dilonei E1=2 E2=3, E3=1, E4=4 kai tha exei dikaioma na ta allazei

//==============================================

pos allazoume grammi kata tin eggrafi se ena arxeio diladi i epolmeni timi
na paei apo kato


//================================================
otan simplirono ta stoixeia mias formas kai patao submin mou bgazei pali tin idia forma

autos einai okodikas pou kaneis insert

Κώδικας: Επιλογή όλων

<?php ob_start&#40;&#41;; ?>
<html>
<head>
<title>InsertAdmin.php</title>
</head>
<body>

<?php

$CodeAdmin = $_POST &#91;'CodeAdmin '&#93;;
$FirstName = $_POST &#91;'FirstName'&#93;;
$LastName  = $_POST &#91;'LastName'&#93;;
$UserName  = $_POST &#91;'UserName'&#93;;
$Password  = $_POST &#91;'Password'&#93;;
$Active    = $_POST &#91;'Active'&#93;;

$con = mysql_connect &#40;"localhost", "root", ""&#41;;
mysql_select_db &#40;"dbase", $con&#41;;

touch&#40;"Administrator.txt"&#41;;

if &#40;!$CodeAdmin || !$FirstName || !$LastName || !$UserName || !$Password || !$Active&#41;
&#123;
  header &#40;"Location&#58; InsertAdmin.html"&#41;;
  exit;
&#125;

 //eisagogh stoixeion ston pinaka studen
if &#40; $CodeAdmin  == $_POST &#91;'CodeAdmin '&#93; || $FirstName == $_POST &#91;'FirstName'&#93; || $LastName == $_POST &#91;'LastName'&#93; ||
     $UserName  == $_POST &#91;'UserName'&#93; || $Password == $_POST &#91;'Password'&#93; || $Active == $_POST &#91;'Active'&#93;&#41;
&#123;
    $file = fopen&#40;"Administrator.txt", "a"&#41;;
    $sql = "INSERT INTO administrator values &#40;'$CodeAdmin ', '$FirstName', '$LastName', '$UserName', '$Password', '$Active'&#41;";
    $result=mysql_query&#40;$sql, $con&#41; or die &#40;mysql_error&#40;&#41;&#41;;

  if &#40;$result&#41;
  &#123;
    echo "&#199; &#197;&#227;&#227;&#241;&#225;&#246;&#231; &#212;&#239;&#245; Administrator &#204;&#229; &#202;&#249;&#228;&#233;&#234;&#252; $CodeAdmin  &#197;&#227;&#233;&#237;&#229; &#197;&#240;&#233;&#244;&#245;&#247;&#254;&#242;";
    fwrite &#40;$file, $CodeAdmin&#41;;
    fwrite &#40;$file,  ", "&#41;;
    fwrite &#40;$file, $FirstName&#41;;
    fwrite &#40;$file,  ", "&#41;;
    fwrite &#40;$file, $LastName&#41;;
    fwrite &#40;$file,  ", "&#41;;
    fwrite &#40;$file, $Active&#41;;
    fclose &#40;$file&#41;;

    $msg="<p><b>&#195;&#233;&#225; &#205;&#225; &#211;&#245;&#237;&#228;&#229;&#232;&#229;&#223;&#244;&#229; &#208;&#225;&#244;&#222;&#243;&#244;&#229; <a href=Login.html> &#229;&#228;&#254; </a></b></p>";
    $msg1="<p><b>&#195;i&#225; &#205;&#225; &#204;&#229;&#244;&#225;&#246;&#229;&#241;&#232;&#222;&#244;&#229; &#211;&#244;&#231;&#237; &#193;&#241;&#247;&#233;&#234;&#222; &#211;&#229;&#235;&#223;&#228;&#225; &#208;&#225;&#244;&#222;&#243;&#244;&#229; <a href=Choice.html> &#229;&#228;&#254; </a></b></p>";
  &#125;
&#125;
else
&#123;
   echo "&#199; &#197;&#227;&#227;&#241;&#225;&#246;&#231; &#212;&#239;&#245; Administrator &#204;&#229; &#202;&#249;&#228;&#233;&#234;&#252; $CodeAdmin  &#193;&#240;&#221;&#244;&#245;&#247;&#229;";
   $msg="<p><b>&#195;&#233;&#225; &#197;&#227;&#227;&#241;&#225;&#246;&#231; &#212;&#239;&#245; Administrator &#208;&#225;&#244;&#222;&#243;&#244;&#229; <a href=&#201;nsertAdmin.html> &#229;&#228;&#254; </a></b></p>";
   $msg1="<p><b>&#195;i&#225; &#205;&#225; &#204;&#229;&#244;&#225;&#246;&#229;&#241;&#232;&#222;&#244;&#229; &#211;&#244;&#231;&#237; &#193;&#241;&#247;&#233;&#234;&#222; &#211;&#229;&#235;&#223;&#228;&#225; &#208;&#225;&#244;&#222;&#243;&#244;&#229; <a href=Choice.html> &#229;&#228;&#254; </a></b></p>";
&#125;

?>
</html>
</body>

<head>
<title>studen.php</title>
</head>
<body>
<?php

    echo"$msg";
    echo"$msg1";
?>

?>
</html>
</body>
<?php ob_end_flush&#40;&#41;; ?>
 
//==============================================

Κώδικας: Επιλογή όλων

  <html>
<head>
<title>EpilogesLabStuden.html</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
</head>

<form namethod="post" action="Deptstuden.php">
  <table width="45%" border="0">
    <tr>
      <td>&#193;&#197;&#204;</td>
      <td><input name="AEM" type="text" id="AEM">
      e.x 568</td>
    </tr>
    <tr>
      <td>&#208;&#241;&#239;&#244;&#229;&#241;&#225;&#233;&#254;&#244;&#231;&#244;&#225;</td>
      <td><input name="Priority " type="text" id="Priority ">
      e.x 1 - 4 </td>
      </table>
    <p>
    <select name="NameLab">
    <option> E1 </option>
    <option> E2 </option>
    <option> E3 </option>
    <option> E4 </option>
    </select>
    </p>
    
  <p>
    <input type="submit" name="Submit" value="&#197;&#227;&#227;&#241;&#225;&#246;&#222;">
  </p>
</body>
</html>
kai autos einai o kodikas

Κώδικας: Επιλογή όλων

 <?php ob_start&#40;&#41;; ?>
<html>
<head>
<title>Deptstuden.php</title>
</head>
<body>

<?php

$AEM = $_POST &#91;'AEM'&#93;;
$Priority = $_POST &#91;'Priority'&#93;;
$NameLab = $_POST &#91;'NameLab'&#93;;
$CodeDept = $_POST &#91;'CodeDept'&#93;;

$con = mysql_connect &#40;"localhost", "root", ""&#41;;
mysql_select_db &#40;"dbase", $con&#41;;

touch &#40;"DeptStuden.txt"&#41;;

if &#40;!$AEM || !$Priority&#41;
&#123;
  header &#40;"Location&#58; DeptStuden.html"&#41;;
  exit;
&#125;

$sql = "select CodeDept From _studen_Dept Where CodeDept ='$CodeDept'";
$result= mysql_query&#40;$sql&#41;;

if &#40;$NameLab == 'E1'&#41;
&#123;
  $sql = "insert Into Studen_Dept &#40;'AEM', 'CodeDept', 'Priority' &#41;";
  $result = mysql_query&#40;$sql&#41;;
  
if&#40;$result&#41;
  &#123;
    echo "Exete graftei sto Tmhma E2";
  &#125;
&#125;
  if&#40;$NameLab == 'E2'&#41;
  &#123;
      $sql="insert Into Studen_Dept &#40;'$CodeDept', '$AEM', '$Priority' &#41;";
      $result =mysql_query&#40;$sql&#41;;
      
      if &#40;$result&#41;
      &#123;

            echo"Exete graftei sto Tmhma E2";
      &#125;
  &#125;

?>
otan patao submit den kanei insert ston pinaka foitites_tmhmata

//==========================================
pou mporo na bro ton kodika gia ena drag and drop select list
Τελευταία επεξεργασία από το μέλος kingbill την 13 Δεκ 2005 03:10, έχει επεξεργασθεί 1 φορά συνολικά.

panosru
WebDev Moderator
Δημοσιεύσεις: 1885
Εγγραφή: 13 Σεπ 2005 16:13
Τοποθεσία: Camp

eisagogi stoixeion stin basi dedomenon se trito pinaka

Δημοσίευση από panosru » 12 Δεκ 2005 23:56

o kodikas apo to arxeio Deptstuden.php pou exeis sto action ths formas sou pou einai?

kingbill
Δημοσιεύσεις: 244
Εγγραφή: 19 Νοέμ 2005 15:06

eisagogi stoixeion stin basi dedomenon se trito pinaka

Δημοσίευση από kingbill » 13 Δεκ 2005 03:08

kato apo tin forma einai

panosru
WebDev Moderator
Δημοσιεύσεις: 1885
Εγγραφή: 13 Σεπ 2005 16:13
Τοποθεσία: Camp

eisagogi stoixeion stin basi dedomenon se trito pinaka

Δημοσίευση από panosru » 13 Δεκ 2005 14:45

op nai sorry den eida to to onoma mesa sto title..

panosru
WebDev Moderator
Δημοσιεύσεις: 1885
Εγγραφή: 13 Σεπ 2005 16:13
Τοποθεσία: Camp

eisagogi stoixeion stin basi dedomenon se trito pinaka

Δημοσίευση από panosru » 13 Δεκ 2005 14:54

pros to paron allakse ayto:

Κώδικας: Επιλογή όλων

  <html>
<head>
<title>EpilogesLabStuden.html</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
</head>

<form namethod="post" action="Deptstuden.php">
  <table width="45%" border="0">
    <tr>
      <td>&#193;&#197;&#204;</td>
      <td><input name="AEM" type="text" id="AEM">
      e.x 568</td>
    </tr>
    <tr>
      <td>&#208;&#241;&#239;&#244;&#229;&#241;&#225;&#233;&#254;&#244;&#231;&#244;&#225;</td>
      <td><input name="Priority " type="text" id="Priority ">
      e.x 1 - 4 </td>
      </table>
    <p>
    <select name="NameLab">
    <option> E1 </option>
    <option> E2 </option>
    <option> E3 </option>
    <option> E4 </option>
    </select>
    </p>
   
  <p>
    <input type="submit" name="Submit" value="&#197;&#227;&#227;&#241;&#225;&#246;&#222;">
  </p>
</body>
</html> 
me ayto:

Κώδικας: Επιλογή όλων

<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-7" />
<TITLE>EpilogesLabStuden.html</TITLE>
</HEAD>
<BODY>
<TABLE border="0" cellspacing="0" cellpadding="0">
<FORM name="myForm" method="post" action="Deptstuden.php">
  <TR>
    <TD>AEM&#58;</TD>
    <TD><INPUT type="text" name="AEM" id="AEM"></TD>
  </TR>
  <TR>
    <TD>Priority&#58;</TD>
    <TD><INPUT type="text" name="Priority" id="Priority"></TD>
  </TR>
  <TR>
    <TD colspan="2" align="left">	<SELECT name="NameLab">
					   				<OPTION>E1</OPTION>
									<OPTION>E2</OPTION>
									<OPTION>E3</OPTION>
									<OPTION>E4</OPTION>
								 	</SELECT>
	</TD>
  </TR>
  <TR>
    <TD colspan="2" align="center"><INPUT type="submit" name="submit" value="submit"></TD>
  </TR>
</FORM>
</TABLE>
</BODY>
</HTML>
Τελευταία επεξεργασία από το μέλος panosru την 13 Δεκ 2005 16:05, έχει επεξεργασθεί 3 φορές συνολικά.

panosru
WebDev Moderator
Δημοσιεύσεις: 1885
Εγγραφή: 13 Σεπ 2005 16:13
Τοποθεσία: Camp

eisagogi stoixeion stin basi dedomenon se trito pinaka

Δημοσίευση από panosru » 13 Δεκ 2005 16:01

allakse to Deptstuden.php me ayto pou sou egrapsa kai tha paiksei mia xara sou exo kanei kati alages ston kodika theorontas kalhtera tora an exo kanei kapoia allagh poud en se boleyei pes to mou:

Κώδικας: Επιλογή όλων

<?PHP
if &#40;strstr&#40;$HTTP_SERVER_VARS&#91;HTTP_ACCEPT_ENCODING&#93;, 'gzip'&#41;&#41; 
&#123; 
  ob_start&#40; 'ob_gzhandler' &#41;; 
&#125;
?>
<HTML>
<HEAD>
<TITLE>Deptstuden.php</TITLE>
</HEAD>
<BODY>
<?php
$AEM         = $_POST&#91;'AEM'&#93;        ;
$Priority    = $_POST&#91;'Priority'&#93;   ;
$NameLab     = $_POST&#91;'NameLab'&#93;    ;
$CodeDept    = $_POST&#91;'CodeDept'&#93;   ; // AYTO APO POU TO KATAXOREI O XRHSTHS?
$host        = "localhost"          ;
$user        = "root"               ;
$pass        = "admin"              ;
$db          = "dbase"              ;
if&#40;!@mysql_connect&#40;$host,$user,$pass&#41;&#41; &#123;
    $error&#91;&#93; = "Error conecting to database -> ".mysql_error&#40;&#41;."<br /> Error number&#58; ".mysql_errno&#40;&#41;;
&#125;
if&#40;!@mysql_select_db&#40;$db&#41;&#41;&#123;
    $error&#91;&#93; = "Error selecting the database &#123;$db&#125;";
&#125;
if&#40;!empty&#40;$error&#41;&#41; &#123;
    foreach&#40;$error as $key => $val&#41; &#123;
        echo&#40;&#40;$key+1&#41;." => &#123;$val&#125; <br />"&#41;;
    &#125;
&#125;

/**
* AYTO TI TO THES? &#58;
* touch &#40;"DeptStuden.txt"&#41;;
* pros to paron sto ebala se coments, opote einai anenergo.
*/

if &#40;empty&#40;$AEM&#41; || empty&#40;$Priority&#41;&#41; &#123;
    header &#40;"Location&#58; EpilogesLabStuden.html"&#41;;
    exit;
&#125;

$sql = "SELECT `CodeDept` FROM `Studen_Dept` WHERE `CodeDept` = '" . $CodeDept . "'";
@$result= mysql_query&#40;$sql&#41;;
while&#40;@$rows = mysql_fetch_assoc&#40;$result&#41;&#41; &#123;
    foreach&#40;$rows as $key => $val&#41; &#123;
        echo&#40;$key . " => " . $val . "<br />"&#41;;
    &#125;
&#125;

$sql_register = "INSERT INTO `Studen_Dept` &#40;`CodeDept`, `AEM`, `Priority`&#41; VALUES &#40;'" . $CodeDept . "', '" . $AEM . "', '" . $Priority . "'&#41;";
if&#40;@$result = mysql_query&#40;$sql_register&#41;&#41; &#123;
    echo&#40;"Exete graftei sto Tmhma &#123;$NameLab&#125;"&#41;;
&#125; else &#123;
    echo&#40;"APOTYXIA EGGRAFHS PARAKALO DOKIMASTE KSANA"&#41;; // LEO EGO TORA &#58;P
&#125;
?>
</BODY>
</HTML>
sou exo kapoies erothseis ston kodika mesa se coment an thes apanthsemou tes thanks.

kingbill
Δημοσιεύσεις: 244
Εγγραφή: 19 Νοέμ 2005 15:06

eisagogi stoixeion stin basi dedomenon se trito pinaka

Δημοσίευση από kingbill » 13 Δεκ 2005 20:40

auto grafo gia na dimiourgisei ena arxeio kai kathos kano insert stin basi na kataxorountai kai sto arxio

panosru
WebDev Moderator
Δημοσιεύσεις: 1885
Εγγραφή: 13 Σεπ 2005 16:13
Τοποθεσία: Camp

eisagogi stoixeion stin basi dedomenon se trito pinaka

Δημοσίευση από panosru » 14 Δεκ 2005 00:48

a.. , den to eipes eksarxhs ayto :P opote prepei na prostheso merikes grames kodika akoma ;) w8 ligo epanerxomai

panosru
WebDev Moderator
Δημοσιεύσεις: 1885
Εγγραφή: 13 Σεπ 2005 16:13
Τοποθεσία: Camp

eisagogi stoixeion stin basi dedomenon se trito pinaka

Δημοσίευση από panosru » 14 Δεκ 2005 01:12

oriste o kodikas sou:

Κώδικας: Επιλογή όλων

<?PHP
if &#40;strstr&#40;$HTTP_SERVER_VARS&#91;HTTP_ACCEPT_ENCODING&#93;, 'gzip'&#41;&#41; 
&#123; 
  ob_start&#40; 'ob_gzhandler' &#41;; 
&#125;
?>
<HTML>
<HEAD>
<TITLE>Deptstuden.php</TITLE>
</HEAD>
<BODY>
<?php
$AEM         = $_POST&#91;'AEM'&#93;        ;
$Priority    = $_POST&#91;'Priority'&#93;   ;
$NameLab     = $_POST&#91;'NameLab'&#93;    ;
$CodeDept    = $_POST&#91;'CodeDept'&#93;   ; // AYTO APO POU TO KATAXOREI O XRHSTHS?
$host        = "localhost"          ;
$user        = "root"               ;
$pass        = "admin"              ;
$db          = "dbase"              ;
$fileName    = "DeptStuden.txt"     ;
if&#40;!@mysql_connect&#40;$host,$user,$pass&#41;&#41; &#123;
    $error&#91;&#93; = "Error conecting to database -> ".mysql_error&#40;&#41;."<br /> Error number&#58; ".mysql_errno&#40;&#41;;
&#125;
if&#40;!@mysql_select_db&#40;$db&#41;&#41;&#123;
    $error&#91;&#93; = "Error selecting the database &#123;$db&#125;";
&#125;
if&#40;!empty&#40;$error&#41;&#41; &#123;
    foreach&#40;$error as $key => $val&#41; &#123;
        echo&#40;&#40;$key+1&#41;." => &#123;$val&#125; <br />"&#41;;
    &#125;
&#125;

if &#40;empty&#40;$AEM&#41; || empty&#40;$Priority&#41;&#41; &#123;
    header &#40;"Location&#58; EpilogesLabStuden.html"&#41;;
    exit;
&#125;

if&#40;!file_exists&#40;$fileName&#41;&#41; &#123;
    touch&#40;$fileName&#41;;
&#125;

$sql_register = "INSERT INTO `Studen_Dept` &#40;`CodeDept`, `AEM`, `Priority`&#41; VALUES &#40;'" . $CodeDept . "', '" . $AEM . "', '" . $Priority . "'&#41;";
if&#40;@$result = mysql_query&#40;$sql_register&#41;&#41; &#123;
    $fp = fopen&#40;$fileName, "a"&#41;;
    $fp_txt = "CodeDept&#58; &#123;$codeDept&#125; | AEM&#58; &#123;$AEM&#125; | Priority&#58; &#123;$Priority&#125;\r\n";
    fputs&#40;$fp, $fp_txt&#41;;
    fclose&#40;$fp&#41;;
    echo&#40;"Exete graftei sto Tmhma &#123;$NameLab&#125;<Br />"&#41;;
&#125; else &#123;
    echo&#40;"APOTYXIA EGGRAFHS PARAKALO DOKIMASTE KSANA"&#41;; // LEO EGO TORA &#58;P
&#125;
/**
* o parakato kodikas sou emfanizei ta stoixia &#40;CodeDept&#41; apo ton pinaka &#40;Studen_Dept&#41; opou to &#40;CodeDept&#41; isoute me to &#40;$CodeDept&#41; opou exei epileksei. 
* giati den thes na emfanizei ola ta stoixia tou pinaka?
*/
$sql = "SELECT `CodeDept` FROM `Studen_Dept` WHERE `CodeDept` = '" . $CodeDept . "'";
@$result= mysql_query&#40;$sql&#41;;
while&#40;@$rows = mysql_fetch_assoc&#40;$result&#41;&#41; &#123;
    foreach&#40;$rows as $key => $val&#41; &#123;
        echo&#40;$key . " => " . $val . "<br />"&#41;;
    &#125;
&#125;
?> <br /> <br /> <?
/**
* o parakato kodikas sou emfanizei ana shra ta stoixeia pou exeis kataxorisei sto arxeio ta opoia fysiologika einai idia me ayta ths bashs dedomenon.
*/
$file = file&#40;$fileName&#41;;
foreach&#40;$file as $key => $val&#41; &#123;
    echo $key . " --> " . $val . "<br />";
&#125;
?>
</BODY>
</HTML>

Απάντηση

Επιστροφή στο “PHP Προγραμματισμός”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 1 επισκέπτης