| | |
help with my scripot PLEASE!!! anyone?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2009
Posts: 31
Reputation:
Solved Threads: 0
Can anyone please help here I have a form that i wish the user to select a product from a drop down box and then query it in a mysql then i would like to the user to input a number in the next field the press the submit button, then the form should do some simple maths and display it in the next field. now 3 things my code does not do 1/ the math and display it 2/the user input and the product i would like to remain after the form has been submitted 3/ also can anyone give some idea of how to get the form to calculate without a submitt button. here is my code:
i have only one row for lenth of thread perposes but all the php is there thanks in advance anyone
PHP Syntax (Toggle Plain Text)
<form action="scdc_selfcompletion.php" method="post"> <select name="bap10"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td colspan = '3'>Total Savings and Expenditure</td> <td> </td> <td> </td> </tr> </table> <input type="Submit" name="select" value="select"> </form> <?php $select = $_POST['select']; // if something has been chosen if (!empty($select)) { // get the chosen value $bap1 = $_POST['bap1']; $bappledging1 = $_POST['pledging1']; $bap2 = $_POST['bap1']; $bappledging2 = $_POST['pledging1']; $bap3 = $_POST['bap1']; $bappledging3 = $_POST['pledging1']; $bap4 = $_POST['bap1']; $bappledging4 = $_POST['pledging1']; $bap5 = $_POST['bap1']; $bappledging5 = $_POST['pledging1']; $bap6 = $_POST['bap1']; $bappledging6 = $_POST['pledging1']; $bap7 = $_POST['bap1']; $bappledging7 = $_POST['pledging1']; $bap8 = $_POST['bap1']; $bappledging8 = $_POST['pledging1']; $bap9 = $_POST['bap1']; $bappledging9 = $_POST['pledging1']; $bap10 = $_POST['bap1']; $bappledging10 = $_POST['pledging1']; // select the type from the database // database connection details (change to whatever you need) $HOST = 'localhost'; $DATABASE = ''; $USER = ''; $PASSWORD = ''; } // connect to database if(!$conn=mysql_connect('','','')) { echo("<li>Can't connect to $HOST as $USER"); echo("<li>mysql Error: ".mysql_error()); die; } // select database if (!mysql_select_db($DATABASE,$conn)) { echo("<li>We were unable to select database $DATABASE"); die; } // if everything successful create query // this selects all rows where the type is the one you chose in the dropdown // * means that it will select all columns, ie name and type as i said above $bap1_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap1'"; $bap2_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap2'"; $bap3_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap3'"; $bap4_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap4'"; $bap5_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap5'"; $bap6_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap6'"; $bap7_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap7'"; $bap8_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap8'"; $bap9_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap9'"; $bap10_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap10'"; //product 1 sum $result = mysql_query($bap1_sql_query,$conn) or die('Invalid query: ' . mysql_error()); $details = mysql_fetch_array($result); $bap1units = $bappledging1 = $_POST['pledging1']; $bap1mes = $details['mesurements']; $bapanswer1 = $bap1mes*$bap1units; ?>
•
•
Join Date: Jan 2009
Posts: 49
Reputation:
Solved Threads: 7
•
•
•
•
Can anyone please help here I have a form that i wish the user to select a product from a drop down box and then query it in a mysql then i would like to the user to input a number in the next field the press the submit button, then the form should do some simple maths and display it in the next field. now 3 things my code does not do 1/ the math and display it 2/the user input and the product i would like to remain after the form has been submitted 3/ also can anyone give some idea of how to get the form to calculate without a submitt button. here is my code:
i have only one row for lenth of thread perposes but all the php is there thanks in advance anyonePHP Syntax (Toggle Plain Text)
<form action="scdc_selfcompletion.php" method="post"> <select name="bap10"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td colspan = '3'>Total Savings and Expenditure</td> <td> </td> <td> </td> </tr> </table> <input type="Submit" name="select" value="select"> </form> <?php $select = $_POST['select']; // if something has been chosen if (!empty($select)) { // get the chosen value $bap1 = $_POST['bap1']; $bappledging1 = $_POST['pledging1']; $bap2 = $_POST['bap1']; $bappledging2 = $_POST['pledging1']; $bap3 = $_POST['bap1']; $bappledging3 = $_POST['pledging1']; $bap4 = $_POST['bap1']; $bappledging4 = $_POST['pledging1']; $bap5 = $_POST['bap1']; $bappledging5 = $_POST['pledging1']; $bap6 = $_POST['bap1']; $bappledging6 = $_POST['pledging1']; $bap7 = $_POST['bap1']; $bappledging7 = $_POST['pledging1']; $bap8 = $_POST['bap1']; $bappledging8 = $_POST['pledging1']; $bap9 = $_POST['bap1']; $bappledging9 = $_POST['pledging1']; $bap10 = $_POST['bap1']; $bappledging10 = $_POST['pledging1']; // select the type from the database // database connection details (change to whatever you need) $HOST = 'localhost'; $DATABASE = ''; $USER = ''; $PASSWORD = ''; } // connect to database if(!$conn=mysql_connect('','','')) { echo("<li>Can't connect to $HOST as $USER"); echo("<li>mysql Error: ".mysql_error()); die; } // select database if (!mysql_select_db($DATABASE,$conn)) { echo("<li>We were unable to select database $DATABASE"); die; } // if everything successful create query // this selects all rows where the type is the one you chose in the dropdown // * means that it will select all columns, ie name and type as i said above $bap1_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap1'"; $bap2_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap2'"; $bap3_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap3'"; $bap4_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap4'"; $bap5_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap5'"; $bap6_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap6'"; $bap7_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap7'"; $bap8_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap8'"; $bap9_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap9'"; $bap10_sql_query = "SELECT * FROM Behaviour WHERE Product LIKE '$bap10'"; //product 1 sum $result = mysql_query($bap1_sql_query,$conn) or die('Invalid query: ' . mysql_error()); $details = mysql_fetch_array($result); $bap1units = $bappledging1 = $_POST['pledging1']; $bap1mes = $details['mesurements']; $bapanswer1 = $bap1mes*$bap1units; ?>
First - what is the problem - what error do you get?
Second what is this: $select = $_POST['select']; ?
I am not sure this will work, I think you should refer to the select option as $_POST['bap10']
Third - why are you referring to values are $_POST['bap1'] when they belong to $_POST['bap1'];
$_POST['bap10']?
$4th - since select returnes only one value (the selected one), you dont need all these:
php Syntax (Toggle Plain Text)
// get the chosen value $bap1 = $_POST['bap1']; $bappledging1 = $_POST['pledging1']; $bap2 = $_POST['bap1']; $bappledging2 = $_POST['pledging1']; $bap3 = $_POST['bap1']; $bappledging3 = $_POST['pledging1']; $bap4 = $_POST['bap1']; $bappledging4 = $_POST['pledging1']; $bap5 = $_POST['bap1']; $bappledging5 = $_POST['pledging1']; $bap6 = $_POST['bap1']; $bappledging6 = $_POST['pledging1']; $bap7 = $_POST['bap1']; $bappledging7 = $_POST['pledging1']; $bap8 = $_POST['bap1']; $bappledging8 = $_POST['pledging1']; $bap9 = $_POST['bap1']; $bappledging9 = $_POST['pledging1']; $bap10 = $_POST['bap1']; $bappledging10 = $_POST['pledging1'];
Just use $_POST['bap10'] and $_POST['pledging1'] in your sql
that's all
One more thing: why are you using LIKE in your sql but then use exact values. Either use = instead of LIKE or use LIKE '%$val%'
Last edited by peter_budo; Jan 30th, 2009 at 2:22 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Jan 2009
Posts: 31
Reputation:
Solved Threads: 0
aaahhhrrrrr uncle smith i have heard all about you from Ardav he sais you are a legend and a better programmer, But thats a different story 1/ I get no error messages whatsoever i see what i should see but it just does not do anything?
2/$select = $_POST['select']; ? this is a variable for the submit button
3/Are you sying i should just use $_POST['bap1']; in my script and not turn them into variables, well at least that is what i think i am doing with them
4/ and the forth i will try cause i think i know what you mean!
2/$select = $_POST['select']; ? this is a variable for the submit button
3/Are you sying i should just use $_POST['bap1']; in my script and not turn them into variables, well at least that is what i think i am doing with them
4/ and the forth i will try cause i think i know what you mean!
grab a prewritten shopping cart script from hotscripts or somewhere, and \"borrow\" their method
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
Join Date: Jan 2009
Posts: 49
Reputation:
Solved Threads: 7
•
•
•
•
aaahhhrrrrr uncle smith i have heard all about you from Ardav he sais you are a legend and a better programmer, But thats a different story 1/ I get no error messages whatsoever i see what i should see but it just does not do anything?
2/$select = $_POST['select']; ? this is a variable for the submit button
3/Are you sying i should just use $_POST['bap1']; in my script and not turn them into variables, well at least that is what i think i am doing with them
4/ and the forth i will try cause i think i know what you mean!
You normally dont need the value of the submit button. I mean, the button is just used to submit the form and since there is usually only one submit button in the form, you dont need to extract its value.
And yes, you only need one sql in your script - it will be automatically populated with the value of selected item.
Last edited by uncle_smith; Jan 29th, 2009 at 12:24 pm.
•
•
Join Date: Jan 2009
Posts: 31
Reputation:
Solved Threads: 0
I have posted the whole script because i think i may be on the wrong track here i cant get it to work!! if you want to see the form as now to get a better ides of what i want to do go here
PHP Syntax (Toggle Plain Text)
<?php session_name('scdc'); session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php // select the type from the database // database connection details (change to whatever you need) $HOST = 'localhost'; $DATABASE = 'k26bruc_cambsdata'; $USER = '; $PASSWORD = '; // connect to database if(!$conn=mysql_connect('localhost','','')) { echo("<li>Can't connect to $HOST as $USER"); echo("<li>mysql Error: ".mysql_error()); die; } // select database if (!mysql_select_db($DATABASE,$conn)) { echo("<li>We were unable to select database $DATABASE"); die; } ?> <p>Self Completion For : <?php echo(''.$_SESSION['ParishName'].''); ?> <form action="scdc_selfcompletion.php" method="post"> <table width="800" border="1" cellspacing="2" cellpadding="3"> <tr> <td colspan = '5'>Behaviour Alteration</td> </tr> <tr> <td> </td> <td>Product Type</td> <td>Number Pledging</td> <td>Energy Saved</td> <td>Investment By The Community</td> </tr> <tr> <td width="15%">Product 1</td> <td width="27%"> <select name="bap1"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging1" type="text" id="pledging" maxlength="5" /> </td> <td width="20%"><?php echo(''.$details['mesurements'].'')?></td> <td width="19%"> </td> </tr> <tr> <td>Product 2</td> <td width="27%"> <select name="bap2"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging2" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td>Product 3</td> <td width="27%"> <select name="bap3"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging3" type="text" id="pledging" maxlength="10" /> </td> <td> </td> <td> </td> </tr> <tr> <td>Product 4</td> <td width="27%"> <select name="bap4"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging4" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td>Product 5</td> <td width="27%"> <select name="bap5"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging5" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td>Product 6</td> <td width="27%"> <select name="bap6"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging6" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td>Product 7</td> <td width="27%"> <select name="bap7"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging7" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td>Product 8</td> <td width="27%"> <select name = "bap8"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging8" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td>Product 9</td> <td width="27%"> <select name="bap9"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging9" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td>Product 10</td> <td width="27%"> <select name="bap10"> <option selected="selected">Select One</option> <option value="Energy Efficient Cooking">Energy Efficient Cooking</option> <option value="Re-Usable Bags">Re-Usable Bags</option> <option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option> <option value="No Stand By">No Stand By</option> <option value="Use Energy Meter">Use Energy Meter</option> <option value="Use Radio Other Than TV">Use Radio Other Than TV</option> <option value="Recycling">Recycling</option> <option value="Stop Junk Mail">Stop Junk Mail</option> </select> </td> <td width="19%"> <input name="pledging" type="text" id="pledging" maxlength="5" /> </td> <td> </td> <td> </td> </tr> <tr> <td colspan = '3'>Total Savings and Expenditure</td> <td> </td> <td> </td> </tr> </table> <input type="Submit" name="select" value="select"> </form> <?php // if something has been chosen if (!empty($select)) { // select the type from the database // database connection details (change to whatever you need) $HOST = 'localhost'; $DATABASE = ''; $USER = '; $PASSWORD = ''; } // connect to database if(!$conn=mysql_connect('localhost','','')) { echo("<li>Can't connect to $HOST as $USER"); echo("<li>mysql Error: ".mysql_error()); die; } // select database if (!mysql_select_db($DATABASE,$conn)) { echo("<li>We were unable to select database $DATABASE"); die; } // if everything successful create query // this selects all rows where the type is the one you chose in the dropdown // * means that it will select all columns, ie name and type as i said above $_POST['bap1'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap1'"; $_POST['bap2'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap2'"; $_POST['bap3'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap3'"; $_POST['bap4'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap4'"; $_POST['bap5'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap5'"; $_POST['bap6'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap6'"; $_POST['bap7'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap7'"; $_POST['bap8'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap8'"; $_POST['bap9'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap9'"; $_POST['bap10']= "SELECT * FROM Behaviour WHERE Product LIKE '$bap10'"; //product 1 sum $result = mysql_query($_POST['bap1'],$conn) or die('Invalid query: ' . mysql_error()); $details = mysql_fetch_array($result); $bap1units = $bappledging1 = $_POST['pledging1']; $bap1mes = $details['mesurements']; $bapanswer1 = $bap1mes*$bap1units; ?> </body>
gpit:
I noticed that your markup is repeated 10 times. pHp's for or while loop is made for this sort of stuff. I'd really suggest that you use a php loop to cut 250 lines to 25. It will be far more manageable - one change - all change.
That's your whole code for the form and table. If you need to add or subtract products, just change the
I have to say, creating your own shopping cart is laudable, but terribly difficult. I wouldn't fancy it. There are loads of off-the-shelf solutions, as already suggested. You may be better off with those. If you're going to take online payment, I would definitely discourage you from "rolling your own". If you're just taking orders, fine.
I noticed that your markup is repeated 10 times. pHp's for or while loop is made for this sort of stuff. I'd really suggest that you use a php loop to cut 250 lines to 25. It will be far more manageable - one change - all change.
PHP Syntax (Toggle Plain Text)
<p>Self Completion For : <?php echo(''.$_SESSION['ParishName'].''); ?> <form action="scdc_selfcompletion.php" method="post"> <table width="800" border="1" cellspacing="2" cellpadding="3"> <tr> <td colspan = '5'>Behaviour Alteration</td> </tr> <tr> <td> </td> <td>Product Type</td> <td>Number Pledging</td> <td>Energy Saved</td> <td>Investment By The Community</td> </tr> <?php for($x = 1;$x <= 10,$x += 1){ echo "\n<tr>\n\t<td>Product {$x}</td>\n\t<td width=\"27%\">\n\t<select name=\"bap{$x}\">\n\t\t<option selected=\"selected\">Select One</option>\n\t\t<option value=\"Energy Efficient Cooking\">Energy Efficient Cooking</option>\n\t\t<option value=\"Re-Usable Bags\">Re-Usable Bags</option>\n\t\t<option value=\"Keep Fridge/Freezer Ice Free\">Keep Fridge/Freezer Ice Free</option>\n\t\t<option value=\"No Stand By\">No Stand By</option>\n\t\t<option value=\"Use Energy Meter\">Use Energy Meter</option>\n\t\t<option value=\"Use Radio Other Than TV\">Use Radio Other Than TV</option>\n\t\t<option value=\"Recycling\">Recycling</option>\n\t\t<option value=\"Stop Junk Mail\">Stop Junk Mail</option>\n\t</select>\n\t</td>\n\t<td width=\"19%\">\n\t<input name=\"pledging\" type=\"text\" id=\"pledging\" maxlength=\"5\" />\n\t</td>\n\t<td> </td>\n\t<td> </td>\n</tr>\n"; } ?> <tr> <td colspan = '3'>Total Savings and Expenditure</td> <td> </td> <td> </td> </tr> </table> <input type="Submit" name="select" value="select"> </form>
That's your whole code for the form and table. If you need to add or subtract products, just change the
$x <= 10 value.I have to say, creating your own shopping cart is laudable, but terribly difficult. I wouldn't fancy it. There are loads of off-the-shelf solutions, as already suggested. You may be better off with those. If you're going to take online payment, I would definitely discourage you from "rolling your own". If you're just taking orders, fine.
•
•
Join Date: Aug 2007
Posts: 165
Reputation:
Solved Threads: 18
•
•
•
•
You folks are really helpful and knowledgeable. I wish I knew as much. I'm just a humble DreamWeaver user.
Don't laugh.
Well, okay you can. Where would I go to learn this stuff?
- HTML and CSS specs
- PHP Manual
- MySQL manual(s)
- JavaScript guide
- Learn AJAX
- Hip Pocket Guide to HTML
- HTML, XHTML & CSS
- VIM Quick Reference Card
So:
- sign up for a solid week of transcendental meditation to clear your mind of WYSIWYG web programming poison
- teach yourself to become proficient using the vim/vi text editor
- teach yourself the basics, the fundamentals, of relational database design and applications
- teach yourself the basics, the fundamentals, of programming
- teach yourself the basics, the fundamentals, of typesetting
- teach yourself the basics of whitespace and visual contrast
- teach yourself the difference between information and its presentation, and the difference between content management and presentation management
- teach yourself the basics of PHP
- teach yourself the basics of HTML 4.01
- teach yourself the basics of styles and CSS
- teach yourself the basics of accessing a MySQL DB using PHP
- design a simple, one-table personal schedule DB
- write a simple, dynamic web page that lets you add items to the DB, delete and change those items, and display them on the page
- access this page from Konqueror, Iceweasel, Firefox, Opera, Epiphany, IE and any other browsers you can find; make your page appear and function the same on all of them
When your single dynamic web page works satisfactorily and looks presentable, you'll be an apprentice LAMP web site programmer. This process should take you six to twelve months if you do nothing else.
Darn. It almost fit into 12 steps. Call it Fester's 14-Step Web WYSIWYG Recovery Program.
N
![]() |
Other Threads in the PHP Forum
- Previous Thread: stripslashes problem
- Next Thread: Hello Again Help with forms
Views: 469 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl customizableitems database date directory display download dynamic echo email error file files folder form format forms forum function functions google headmethod href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail malfunctioning menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






