...

View Full Version : pricelist return



p206ab
06-03-2012, 08:22 PM
So I'm having this 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.

p206ab
06-04-2012, 02:28 PM
Awesome, thanks again! :) :thumbsup:

p206ab
06-07-2012, 10:19 AM
So I made this like you suggested:



<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).
http://shrani.najdi.si/?23/CQ/2Fhnck9Q/capture.png


In the end I made php script who runs this query


<?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". :confused:
Any ideas what is missing in php?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum