Показать сообщение отдельно

  #4  
Старый 16.06.2009, 18:51
FireFenix
Постоянный
Регистрация: 03.06.2009
Сообщений: 385
С нами: 8915117

Репутация: 389
По умолчанию

Думаю вы хотели как-то так
PHP код:
<form id="form" name="form" method="post" action="?">
  <select id="type_1" name="type_1">
    <option value="0" selected="selected">Выберите счет:</option>
    <option value="1">Касса</option>
  </select>  
  <select id="number_1" name="number_1">
    <option value="0" selected="selected">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
  </select>
  <br>
  <select id="type_2" name="type_2">
    <option value="0" selected="selected">Выберите счет:</option>
    <option value="1">Касса</option>
  </select>  
  <select id="number_2" name="number_2">
    <option value="0" selected="selected">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
  </select>
  <br>
  <input type="submit" value="Отправить">
</form>

<?php

class Bill 
{
  var 
$number;
  var 
$type;
  var 
$number1;
  var 
$type1;
  var 
$typeofinformation;
  
  function 
display() 
  {
    echo(
'Дебет: ' . $this->number . '<br>');
    echo(
'Кредит: ' . $this->number1 . '<br>');
  
    if (
$this->type == 'active') 
    {
      if(
$this->type1 == 'active') 
      {
        
$typeofinformation = '1';
      }    
    }
    
    if (
$this->type == 'passive') 
    {
      if(
$this->type1 == 'passive') 
      {
        
$typeofinformation = '2';
      }    
    }
    
    if (
$this->type == 'active') 
    {
      if(
$this->type1 == 'passive')
      {
        
$typeofinformation = '3 или 4';
      }    
    }
  }
}

if (isset(
$_POST['type_1']) && isset($_POST['type_2']) && isset($_POST['number_1']) && isset($_POST['number_2']))
{
  
$bill = new Bill();
  
  switch (
$_POST['type_1'])
  {
    case 
'0':
      
$bill->type = 'passive';
    break;
    
    case 
'1':
      
$bill->type = 'active';
    break;
  }
  
  switch (
$_POST['type_2'])
  {
    case 
'0':
      
$bill->type1 = 'passive';
    break;
    
    case 
'1':
      
$bill->type1 = 'active';
    break;
  }
  
  
$bill->number = $_POST['number_1'];
  
$bill->number1 = $_POST['number_2'];
  
  
$bill->display();
  
  echo(
'<hr>' . $bill->type . ' - ' . $bill->number . '<br>' . $bill->type1 . ' - ' . $bill->number1 . '<br>' . $typeofinformation . '<hr>');
}

?>
 
Ответить с цитированием