Location: PHPKode > projects > Einkaufszettelgenerator > EZettel0.1/speise_to_db.php
<?
session_start();
$us= $HTTP_SESSION_VARS['uid'];
//echo "user=$us<br>"; 
?>
<HTML>
<LINK REL="stylesheet" TYPE="text/css" HREF="menu.css"> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head> 
<body class="speise"> 
<?

include("menu.ini"); 

$strsql_t = "select type_id from speise_type where (type_name='$_POST[speise_type]' and user_id='$us');";
$result_t = mysql_query($strsql_t, $connection);
   $j=0;
    while ( $row = mysql_fetch_row($result_t) )
       {
        $j+=1;
       $_POST[speise_type]=$row[0]; 
        }           


 $strsql = "insert into speise (speise_name, speise_type, speise_recept, user_id) VALUES ('$_POST[speise_name]','$_POST[speise_type]','$_POST[speise_recept]','$us');";

//echo "str=$strsql<br>";
 $result = mysql_query($strsql, $connection);  


 for ($k = 1; $k <= 10; $k++)
   {
    $prod_id="prod_id_$k";
 //    echo "POST[$prod_id]=$_POST[$prod_id]<P>";   

     if ($_POST[$prod_id]!='')
     {
      //echo "prod_type=$_POST[$prod_type]<P>";
      //echo "prod_id=$_POST[$prod_id]<P>"; 


      $strsql_2 = "select prod_id from product  where (prod_name='$_POST[$prod_id]');";
      $result_2 = mysql_query($strsql_2, $connection);
       $t=0;
       while ( $row_2 = mysql_fetch_row($result_2) )
         {
          $t+=1;
          $_POST[$prod_id]=$row_2[0];
 //        echo "new POST[$prod_id]=$_POST[$prod_id]<P>";    
          }     

 //     echo "speise_name =$_POST[speise_name]<P>";
       $strsql_3 = "select speise_id from speise  where (speise_name ='$_POST[speise_name]' and user_id='$us');";
       $result_3 = mysql_query($strsql_3, $connection);
       $s=0;
       while ( $row_3 = mysql_fetch_row($result_3) )
         {
          $s+=1;

 //echo "speise_id=$row_3[0]<P>";
 $sid=$row_3[0];
        $strsql_4 = "Insert into  teil (speise_id, prod_id) Values ('$row_3[0]', '$_POST[$prod_id]');";

//echo "$strsql <P>";

        $result_4 = mysql_query($strsql_4, $connection); 
           }
  }
}
  $strsql_5 = "select p.speise_name,p.speise_id, t.type_name ,p.speise_recept from  speise p, speise_type t where ( (p.speise_name='$_POST[speise_name]') and (p.speise_type=t.type_id) and p.speise_id='$sid' and t.user_id='$us');"; 
  
  //echo "str_select=$strsql_5<br>";
  
// echo "str=$strsql_5<br>";
  $result_5 = mysql_query($strsql_5, $connection);
   $r=0;
  while ( $row_5 = mysql_fetch_row($result_5) )
   {
 $r+=1;
 echo "<center><B>$row_5[0]</B><BR>$row_5[2]</center><P>";
 echo "<B>Teiles</B>:";    

$strsql_6 = "select p.prod_name from  product p,  teil t where ( (t.speise_id='$row_5[1]')&&(p.prod_id=t.prod_id));";
  $result_6 = mysql_query($strsql_6, $connection);
   $y=0;
  while ( $row_6 = mysql_fetch_row($result_6) )
   {
 $y+=1;
 echo "$row_6[0] ";
  }
echo "<P><BLOCKQUOTE>$row_5[3]</BLOCKQUOTE><P>";     

    }
?>
<center><A HREF=input_speise.php>Ввести новый рецепт</a>&nbsp;&nbsp;<A HREF=start.php>На первую страницу</a></center>      

</HTML> 
Return current item: Einkaufszettelgenerator