Jump to content

xoluz

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

xoluz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okay, so basicly I have the following code: [b]Searchform on page1.php[/b] [code] <form name="form" method="post" action="page2.php"> <input name="carbrand" type="text" size="16" maxlength="16"></td> <input type="submit" name="Submit" value="Search"> </form> [/code] People should enter carbrand in the textfield, like 'BMW' or 'Ford'. Then they press 'Search' and they should go to page2.php. [b]Page2.php looks like this:[/b] [code] include 'connect_to_db.php'; $carbrand = ($_POST['carbrand']); $mysql_query = "SELECT * FROM carbrands WHERE carbrand='$carbrand'"; $result = mysql_query($mysql_query); while ($row = mysql_fetch_object($result)) { [/code] Now that was the PHP-code. When I want to echo something, I use this code: [code] <?php print "$row->carnumber"; ?> <?php print "$row->carbrand"; ?> <?php print "$row->cardescription"; ?> <?php print "$row->carprice"; ?> [/code] Goal: I want to show ALL cars of the brand what was inserted before on the form of page1.php. Problem: The code is working, BUT it's only showing the first character of the value in the database. So I get this: [code] 1         |       B       |        T          |          2 1         |       B       |        T          |          2 3         |       B       |        T          |          3 8         |       B       |        P          |          1 [/code] Instead of this: [code] 13344  | BMW  |  This is a BMW 318i     |  21000,- 13367  | BMW  |  This is a BMW 325Ci   | 28000,- 34344  | BMW  |  This is a BMW 325M3  | 31000,- 89333  | BMW  |  Perfect BMW 525        |  19999,- [/code] See, it's only echoing the first character.. ;( edit: problem solved, I shouldn't use the foreach command.. :P
  2. [!--quoteo(post=356601:date=Mar 20 2006, 06:40 PM:name=DjMikeS)--][div class=\'quotetop\']QUOTE(DjMikeS @ Mar 20 2006, 06:40 PM) [snapback]356601[/snapback][/div][div class=\'quotemain\'][!--quotec--] What is it supposed to do? Looks like a search form ? [/quote] No, I have a form where I enter this carnumber. That form is linked to the form I posted before. It should display all cars and stuff, but it's only displaying the first letter of all cars..
  3. Hello there, I've got some troubles echoing values... First of all, I have the following form: [code] <form name="form" method="POST"> <table width="806" border="0">   <tr>     <td width="160">Number</td>     <td width="211">Description</td>     <td width="153">Price / Amount</td>     </tr> <?php $number = ($_POST['number']); $query = "select * from cars where number='$number'"; $result = mysql_query($query); while ($row = mysql_fetch_object($result)) { foreach ($row AS $array) { ?>   <tr>     <td><?php echo $array["carnumber"]; ?></td>     <td><?php echo $array["cardescription"]; ?></td>     <td><?php echo $array["carppamount"]; } }?></td>     </tr> </table> </form> [/code] But it's not really working, because it's only echo-ing the first letter of the value from the database :S. Does anyone know how that happened?
  4. Hey there! How can I calculate till 2 decimals after the comma? I've got something like this now [code] $price1 = array_sum($prices); $test = $price1 * 0.7; echo $test; [/code] Now I'm getting values like 32.233 or 500.300, but they should be 32,23 and 500,30 :s
  5. [!--quoteo(post=355956:date=Mar 18 2006, 04:05 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 18 2006, 04:05 AM) [snapback]355956[/snapback][/div][div class=\'quotemain\'][!--quotec--] You need to use "==" not "=". But you said you wanted this to happen "When the '$formtotal' is more than 50 000" [code]<?php if ($formtotal > 50000)      $discount = $formtotal * 0.1; else      echo 'no discount<br>'; $total = $formtotal - $discount; echo 'Total: $total'; ?>[/code] Ken [/quote] Thanks! That works perfect :) And I forgot about the ==, it should be > like you said ;)
  6. Hi was wondering something, I've got the following code now: [code] $ruletotal = $array['amount'] * $array['price']; $formtotal = array_sum($ruletotal) [/code] This thing works imo, but now I want to add something to it. When the '$formtotal' is more than 50 000, I want to calculate 10% of it. So i got this added, but something isn't working: [code] if ($formtotal = 50000) { $discount = $formtotal /100*10; } else { echo 'no discount';} $total = $formtotal - $discount; echo 'Total: $total'; [/code] Could someone help me out here..? :)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.