The Buffalo PHP User Group Message Board › Need help with php script

Need help with php script

Ray N.
RayNewman
Buffalo, NY
Post #: 1
I have always learned with small, tight blocks of code.
Sort of like "hello world"
Anyhow I want to make a menu that is like ordering a pizza.
drop down menu select size
then drop down select topping
sort of like:
https://www.elbowspac...­
But price is from myqsl
Need to show total price at bottom.
For me to play with:
2 sizes of pizza with two prices (cheese only)
add one topping but price of topping changes with size pizza
hidden id (from mysql) for each item but gets passed on with items/price in submit form.

Blank background
no alignments or photo, I'll add myself.
Just need help with the basic function.

Thanks for any help I can get!!!!

Ray
moleski
user 11001601
Buffalo, NY
Post #: 1
Step one: design the page with HTML, css, and javascript, using hard-coded values for the prices.

I've got a page like that here:

http://www3.canisius.edu/~moleski/101/calc_grade.htm­

If you look at the page source, you should see the javascript that does the summing whenever a field is modified.

Then you wrap the page in PHP, getting the prices you need for the various options and using short PHP calls to fill in the real values for the variables.

Get the data out of the database.

// initialize the data array to pass to ezTable
$data = array();

// Get the data and store it in $data--it will be an array of arrays
// Open the connection to the database.
$mysqli = new mysqli('localhost', 'username', 'password', 'databasename');
if (mysqli_connect_error()) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
// SELECT * FROM `nsrca_paypal` WHERE `paypal_txn_id` = 'WQ9F3928MLC9Y' LIMIT 0, 30
// $sql = 'SELECT * FROM `nsrca_paypal` WHERE `paypal_txn_id` = \''.$txn_id.'\' LIMIT 0, 30 ';
$sql = 'SELECT * FROM `nsrca_paypal` ORDER BY `last_name` ASC ';
if (!($result = mysqli_query($mysqli, $sql))) {
printf("Error: %s\n", mysqli_error($mysqli));
} else {
// Close the connection to the database.
$mysqli->close();
$total_tix = 0;
$by_tix_num = array(); // intialize array to hold ticket number, name, e-mail
// echo one table row per record found
while ($rows = $result->fetch_array(MYSQLI_ASSOC)) { ...



Here's a PHP example that fills in a row in a table with information from PHP variables:

echo('<td><input name="'.$RnCn.'" type="text" id="'.$RnCn.'" value= "'.$inarray[$inarray_index].'"­></td>');


Here is a snippet that mixes PHP into HTML:

<tr bgcolor="#CCCCCC">
<th colspan="<?PHP echo(count($fields_in_program_record)+2)­?>" scope="col"> <?PHP echo($thisday);?></th>
</tr>


Marty
synace
synace
Buffalo, NY
Post #: 25
Ray,

Bring this problem to the next meetup. We'll add it to the regularly running topic: 'I need some help here!'

Thanks!

I have always learned with small, tight blocks of code.
Sort of like "hello world"
Anyhow I want to make a menu that is like ordering a pizza.
drop down menu select size
then drop down select topping
sort of like:
https://www.elbowspac...­
But price is from myqsl
Need to show total price at bottom.
For me to play with:
2 sizes of pizza with two prices (cheese only)
add one topping but price of topping changes with size pizza
hidden id (from mysql) for each item but gets passed on with items/price in submit form.

Blank background
no alignments or photo, I'll add myself.
Just need help with the basic function.

Thanks for any help I can get!!!!

Ray

Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy