Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    pricelist return

    So I'm having this code:

    Code:
     
    <form action="php/pricelist.php" method="post"> 
    <input type="checkbox" name="item1"/> ITEM 1 <br />	
    <input type="checkbox" name="item2" /> ITEM 2	<br />
    <br/>
    <button type="button" ONCLICK=FUNCTION()>Count your price!</button>
    And I'm wondering where can I get some examples for my problem or if anyone of you can help me.
    I want to make a script who would have items values written in SQL database, and then when user would select an item and sumbit its selection, SQL would return price(values) for selected items.

    Any hints, links?

    Thanks.

  • #2
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Awesome, thanks again!

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    So I made this like you suggested:

    Code:
    <input type="checkbox" name="checkMe[]" id="foto"/> photo<br />	 
    <input type="checkbox" name="checkMe[]" id="video"/> video	<br />
    <br/>
    	
    <input type="radio" name="event[]" id="poroka" />Wedding<br />	
    <input type="radio" name="event[]" id="krst" />Baptism<br />	
    <input type="radio" name="event[]" id="obhajilo" />Obhajilo<br />	
    <input type="radio" name="event[]" id="rojstni" />brithday<br />
    
    
    <input type="radio" name="paket[]" id="polni" />Full<br />	
    <input type="radio" name="paket[]" id="delni" />Partial<br />	
    <input type="radio" name="paket[]" id="osnovni" />Basic<br />	
    <input type="radio" name="paket[]" id="osnovniplus" />basic+<br />
    And then made a table in database with 2 columns, one with id's from all of these above and in second are their values (prices).



    In the end I made php script who runs this query
    Code:
    <?php
    
     $host="localhost"; 
    $username="root"; 
    $password="";  
    $db_name="pricelist"; 
    $tbl_name="prices"; 
    
    mysql_connect("$host", "$username", "$password")or die("connection not avaliable"); 
     mysql_select_db("$db_name")or die("can't select database");
    
    $service=$_POST["checkMe"];
    $event=$_POST["event"];
    $package=$_POST["paket"];
    
    $sql = "SELECT SUM(value) AS result FROM prices";
    $result=mysql_query($sql) or trigger_error(mysql_error().$sql);
    echo "Total is" + $result+ "$.";
    ?>
    But it always return just number 4 and nothing else. If I select all boxes or none of them, just "4".
    Any ideas what is missing in php?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •