-
Posts
862 -
Joined
-
Last visited
-
Days Won
1
Posts posted by phppup
-
-
Notice: Undefined variable: result in... line 91
This correcsponds to my: if($result){ towards the end.
-
AFTER CONNECTION:
//save the data on the DB and send the email if(isset($_POST['action']) && $_POST['action'] == 'submitform') { //recieve the variables $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; } $record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : '';//check for $record_id emptiness if(!empty($record_id)){ echo "<pre>", print_r($_POST), "</pre>"; $testtable = array();foreach($_POST as $indexName => $value) { $testtable[] = "$indexName = \"$value\"";} $fields = implode(",", $testtable); $sql=("UPDATE testtable SET $fields WHERE id = $record_id "); echo "<pre>", print_r($_POST), "</pre"; echo "$sql"; $result=mysql_query($sql); } if($result){ echo "Successful"; } else { echo "ERROR"; }
-
Not sure if I was posting it correctly, so i stuck it in 3 different places, and NO MESSAGES
-
No messages. Just the same ERROR message from my own script. So is it not grabbing the fields, or is it not grabbing the record_id number?
-
if(isset($_POST['action']) && $_POST['action'] == 'submitform') { //recieve the variables $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; $record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : ''; if(!empty($record_id)){ $testtable = array();foreach($_POST as $indexName => $value) { $myUpdateList[] = "$indexName = \"$value\"";} $fields = implode(",", $testtable); $sql=("UPDATE testtable SET $fields WHERE id = $record_id "); $result=mysql_query($sql); } if($result){ echo "Successful"; } else { echo "ERROR"; }
EDITed for CODE tags.
-
Got rid of the T-string error. There are no MySQL errors, but the page takes me to MY own ERROR message rather than SUCCESS after submission. SO it's missing something.
I changed the table name to MY testtable name. Are all others AS IS?
-
well, I'm glad you're here, because I'm doing something wrong. I posted it as written:
$testtable = array();foreach($_POST as $indexName => $value) { $myUpdateList[] = "$indexName = \"$value\"";}
$fields = implode(",", $testtable);
$sql=("UPDATE testtable SET $fields WHERE id = $record_id ");
but I was getting a T-string error
-
I need to update fields through a form, but there are MANY fields.
Instead of UPDATE table SET email='$email', name, etc, for EVERY value, is there a shortcut that might loop through all my fields, since I want every one of them to be checked for updated info.
-
Having trouble using the code mentioned. Is it a syntax error? Should MyUpdateList be my database name?
I'm sure it's a minor glitch. Or maybe I'm better of listing each item, as the shortcut is requiring much more work.. LOL
-
After submission I want to be able to pull up a customer record and the LAST 4 DIGITS of the social security number that was provided. What's the best way to do this?
Am I best off having them INPUT the digits into three different fields that will load into the DB as Socxxx, Socxx, and Socxxxx, and just calling the Socxxxx field, or is there a way to 'strip' all but the last 4 digits?
-
No numbers, no characters, just a capitall lettter and the remaining lowercase letters.
Also, if I want toeveviate some of the PHP burden and add this in Javascript, should it go directly ahead of the PHP, or be intertwined with it?
-
So how would I ensure that a name field is SAVED with the first letter capitalized, and the rest all lowercase, regardless of how it was typed into the field?
-
I might want it capitalised so that when I send an email, it can be addressed "Dear Greenballoon" as opposed to greenballon. So, is there a way to do it, or it it best left until I send the email.
-
While we're on the subject, is there a way to ensure that the first letter of a name is captalized, and the rest lowercase? Or is this best handled later on, when the name is being used and called from the DB.
PS: some of us comment are code as to WHAT we are doing because we're just not that good yet, and we need to explain it to ourselves.
-
Each row contains quantities from a form.
I then ECHO the form after submission and ECHO the values.
I would like all values >0 to be BOLD.
while($result=mysql_fetch_array($query)) {$value=result["somerow"];
if ($value>o) {
echo "Some field name <input name='data' type='text' id='bold' value='$value' /><br/>";
} else{ echo "Some field name <input name='data' type='text' value='$value' /><br/>"; }}
the above codeseems promising, but I'm not sure how to LOOP it so it evaluates ALL the values in their fields, or if there might be a better method.
-
Code not working
Getting T-string error:
$myUpdateList = array();foreach($_POST as $indexName => $value) { $myUpdateList[] = "$indexName = \"$value\"";}
$fields = implode(",", $myUpdateList);
$sql=UPDATE pass SET $fields WHERE id = 3;
Am I missing parenthesis or semi colons, or quotes?
-
Yes, the dropdowns were ALL written manually with HTMN (i've since learned there is a php method that's less exhausting).
The id is being input into a field calling it from the DB as record_id.
$record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : '';
-
I appreciate the humor.
It's just that as a newbie, ya never know if htere's some variable at work that you haven't encountered yet.
I was thinking they might have a similar numeric value or name concontination or some sort.
PS: the broccoli is STEAMED.... so at worst it gets soggy. LOL
-
Using 85% dropdowns, and then some standard name,address input fields.
Ummmm, easiest way to provide the $id for the script?
-
And why is my BROCCOLI now BURNT.... i suppose this is more than just you being funny.
And will I ever actually see (or need to use) my BURNT items?
-
I'm just doing what the internet tell me (which is probably why I'm having so much trouble, huh).
So instead of listing them twice, what??
-
Here is the code that was at the top of my INSERT.php code
$roastturkey = $_POST['roastturkey'];
$broccoli = $_POST['broccoli'];
$brisket = $_POST['brisket'];
$carrots = $_POST['carrots'];
and then it repeats as the VALUES to be posted.
I'm still a bit confused about my UPDATE statement.
UPDATe mytable SET (all the post names) WHERE id="id" ...... so the SET is the list of fields, but there's a way to loop through them to avoid listing each one seperately??
Please help. As I've discovered I could have saved LOTS of time had I understood and implemented other PHP shortcuts earlier in this process.
Thanks.
-
Don't have the code yet. I have multiple fields form a form that were input from dropdown menus.
So I would need a loop for each item in row??
-
SO if I have 50 fields in a single row, I need to list them in the same manner as when I input them from the form?
There is now way to simply state that I want the entire ID row to be overwritten (since MySQL will automatically NOT overwrite items that were not changed)?
any easy way to list UPDATE columns
in PHP Coding Help
Posted
OKAY, I pulled out the conditional and it printed:
Array
(
[roastturkey] => 2.00
[broccoli] => 0.00
[brisket] => 6.00
[carrots] => 0.00
[submitpass] => Submit Order
)
1
so now the question is, How will it know which row ID to post the new data to?