0

ここで何が間違っているのかわかりません..テーブルには約125の製品がありますが、テーブルから最後の製品しか得られないため、1つのアイテムしか表示されません...これは、販売担当者と顧客を提供するための簡単な計算機です必要な箱の量と、簡単な見積もりの​​費用。事前に助けてくれてありがとう..

<?php

include('admincik/config.php');
include ('birlikte/ac.thumbs.php'); 

//Retrieves data from MySQL 

 $data = mysql_query("SELECT * FROM Calculator ORDER BY isim") or die(mysql_error()); 
 //Puts it into an array 
 while($info = mysql_fetch_array( $data )) 
 { 
$resim = $info['resim'];
$isim = $info[isim];
$boyut = $info[boyut];
$pcs = $info[adet];
$sqft = $info[sqft];
$price = $info[price];
}
/////////Formdan gelen yada Giden//////////////
$length =htmlspecialchars(stripslashes($_POST['Length'])); 
$width =htmlspecialchars(stripslashes($_POST['Width'])); 
$TileNameList = "<option value=\"$sqft\">$isim $boyut</option>";

/////Matematiksel islemler/////////

$equals = $length * $width;
$box = round($equals / $sqft);
$sqftbox = $box * $sqft;
$TotalPrice = $sqftbox * $price

?>
<div class="ana">
  <table width="900" height="199" border="1">
    <tr>
      <td width="150">Name</td>
      <td width="150">Length</td>
      <td width="150">Width</td>
      <td width="150">Total Sqft Area</td>
      <td width="200">Box Needed /Total Sqft</td>
      <td width="100">Price</td>
    </tr>
    <tr>
      <td><form id="form5" name="form5" method="post" action="">
        <select name="TileName" id="TileName">
<?php echo ($TileNameList); ?>
        </select>
      </td>
      <td><input name="Length" type="text" id="Length"/></td>
      <td><input type="text" name="Width" id="Width"/></td>
      <td><input type="text" name="Sqft" id="Sqft" value="<?php echo ($equals); ?>"/></td>
      <td><?php echo "You will need <span style=\"color:red\">$box</span> Boxes<br> Which is <span style=\"color:red\">$sqftbox</span> "; ?></td>
      <td><?php echo "$$TotalPrice"; ?></td>
    </tr>
    <tr >
      <td colspan="6" align="center">
        <input type="submit" name="Submit" id="Submit" value="Submit" />
      </form></td>

    </tr>
  </table>

</div>
4

1 に答える 1

1

ループは $TileNameList の外側に存在するため、追加されません。それは実際にその値を置き換えます。試す:

<?php

include('admincik/config.php');
include ('birlikte/ac.thumbs.php'); 

//Retrieves data from MySQL 

 $data = mysql_query("SELECT * FROM Calculator ORDER BY isim") or die(mysql_error()); 
 //Puts it into an array 
 while($info = mysql_fetch_array( $data )) 
 { 
$resim = $info['resim'];
$isim = $info[isim];
$boyut = $info[boyut];
$pcs = $info[adet];
$sqft = $info[sqft];
$price = $info[price];
$TileNameList .= "<option value=\"$sqft\">$isim $boyut</option>";   // NOTE THE .=
}
/////////Formdan gelen yada Giden//////////////
$length =htmlspecialchars(stripslashes($_POST['Length'])); 
$width =htmlspecialchars(stripslashes($_POST['Width'])); 


/////Matematiksel islemler/////////

$equals = $length * $width;
$box = round($equals / $sqft);
$sqftbox = $box * $sqft;
$TotalPrice = $sqftbox * $price

?>
<div class="ana">
  <table width="900" height="199" border="1">
    <tr>
      <td width="150">Name</td>
      <td width="150">Length</td>
      <td width="150">Width</td>
      <td width="150">Total Sqft Area</td>
      <td width="200">Box Needed /Total Sqft</td>
      <td width="100">Price</td>
    </tr>
    <tr>
      <td><form id="form5" name="form5" method="post" action="">
        <select name="TileName" id="TileName">
<?php echo ($TileNameList); ?>
        </select>
      </td>
      <td><input name="Length" type="text" id="Length"/></td>
      <td><input type="text" name="Width" id="Width"/></td>
      <td><input type="text" name="Sqft" id="Sqft" value="<?php echo ($equals); ?>"/></td>
      <td><?php echo "You will need <span style=\"color:red\">$box</span> Boxes<br> Which is <span style=\"color:red\">$sqftbox</span> "; ?></td>
      <td><?php echo "$$TotalPrice"; ?></td>
    </tr>
    <tr >
      <td colspan="6" align="center">
        <input type="submit" name="Submit" id="Submit" value="Submit" />
      </form></td>

    </tr>
  </table>

</div>
于 2013-02-08T03:01:39.283 に答える