Re: [PHP] php forms - select menu selected behavior
Troy Oltmanns wrote: I have the code below being used to rifle through a list of available categories and create select options for them. The code is being used to query the database and compare the product category to the current iteration, if there's a match, then add selected code so the category is prechosen. More code (not included) does the saving and all that, I've check phpmyadmin. But when the page submits, the old category appears in the drop down as selected. If I leave the page and come back it's fine, it's just right after it is saved. The form script is being used on itself, in that there is only one file for the form, the submission, etc. All of the other input elements will load the data after being saved, is it something specific to dropdowns, or it is the way the code is being instatiated? All help is much appreciated. Please let me know if anymore info is needed. //MAKE CATEGORIES DROPDOWN $catlist1 = ; // read product $catmatch = SELECT prod_cat0 FROM product WHERE dbi='$dbi';; $catresult = mysql_query($catmatch); $catquery = mysql_fetch_array($catresult); // read categories $sql = SELECT category FROM categories ORDER BY category;; $result = mysql_query($sql); while ($col2 = mysql_fetch_array($result)) { $id = $col2[category]; if ($id == $catquery['prod_cat0']){ $catlist1 .= option value=\$id\ selected=\selected\$id/option; } else { $catlist1 .= option value=\$id\$id/option; } } to instantiate ?=$catlist1? The only data you need from table product is the column prod_cat0, from table categories it's category, so you should read only the needed data instead of using * for better performance. Take the SQL and verify if it returns what you want it to return then. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php forms - select menu selected behavior
On Thu, 2009-04-30 at 11:06 +0200, Marcus Gnaß wrote: Troy Oltmanns wrote: I have the code below being used to rifle through a list of available categories and create select options for them. The code is being used to query the database and compare the product category to the current iteration, if there's a match, then add selected code so the category is prechosen. More code (not included) does the saving and all that, I've check phpmyadmin. But when the page submits, the old category appears in the drop down as selected. If I leave the page and come back it's fine, it's just right after it is saved. The form script is being used on itself, in that there is only one file for the form, the submission, etc. All of the other input elements will load the data after being saved, is it something specific to dropdowns, or it is the way the code is being instatiated? All help is much appreciated. Please let me know if anymore info is needed. //MAKE CATEGORIES DROPDOWN $catlist1 = ; // read product $catmatch = SELECT prod_cat0 FROM product WHERE dbi='$dbi';; $catresult = mysql_query($catmatch); $catquery = mysql_fetch_array($catresult); // read categories $sql = SELECT category FROM categories ORDER BY category;; $result = mysql_query($sql); while ($col2 = mysql_fetch_array($result)) { $id = $col2[category]; if ($id == $catquery['prod_cat0']){ $catlist1 .= option value=\$id\ selected=\selected\$id/option; } else { $catlist1 .= option value=\$id\$id/option; } } to instantiate ?=$catlist1? The only data you need from table product is the column prod_cat0, from table categories it's category, so you should read only the needed data instead of using * for better performance. Take the SQL and verify if it returns what you want it to return then. I tend to do my loops like this: while ($col2 = mysql_fetch_array($result)) { $id = $col2[category]; $selected =($id == $catquery['prod_cat0'])?'selected=selected':''; $catlist1 .= option value=\$id\ $selected$id/option; } Just looks a little neater. 'Course, you could remove the $id line and chuck the value straight into the short if statement there. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php forms - select menu selected behavior
I have the code below being used to rifle through a list of available categories and create select options for them. The code is being used to query the database and compare the product category to the current iteration, if there's a match, then add selected code so the category is prechosen. More code (not included) does the saving and all that, I've check phpmyadmin. But when the page submits, the old category appears in the drop down as selected. If I leave the page and come back it's fine, it's just right after it is saved. The form script is being used on itself, in that there is only one file for the form, the submission, etc. All of the other input elements will load the data after being saved, is it something specific to dropdowns, or it is the way the code is being instatiated? All help is much appreciated. Please let me know if anymore info is needed. //MAKE CATEGORIES DROPDOWN $sql=SELECT * FROM categories ORDER BY category; $catmatch=SELECT * FROM product WHERE dbi='$dbi'; $catresult=mysql_query($catmatch); $catquery=mysql_fetch_array($catresult); //for($a=0;$amysql_fetch_array($catresult)){ //echo $catquery['prod_cat0']; //} $result=mysql_query($sql); $catlist1=; while ($col2=mysql_fetch_array($result)) { $id=$col2[category]; if($id==$catquery['prod_cat0']){ $catlist1.=option value=\$id\ selected=\selected\.$id./option; } else { $catlist1.=option value=\$id\.$id./option; } } to instantiate ?=$catlist1?
Re: [PHP] PHP Forms
On Thu, May 4, 2006 9:57 pm, R. Van Tassel wrote: I am having an issue with a form, basically an order form, with 10 rows. Each row is the same, the rows are being generated by a loop and I am appending the counter of the loop to the name of the form elements (i.e. quantity1, type1, next row = quantity2, type2, etc) Save yourself a lot of headaches and use: NAME=quantity[1] It will be an array when you process it with $_POST -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Forms
I am having an issue with a form, basically an order form, with 10 rows. Each row is the same, the rows are being generated by a loop and I am appending the counter of the loop to the name of the form elements (i.e. quantity1, type1, next row = quantity2, type2, etc) I can't seem to receive the variables without using sessions, which I'm trying not to do. If only the first 2 rows are being filled out and submitted I need to be able to loop through, grab all the variables and print them out. Can anyone give any suggestion?
Re: [PHP] PHP Forms
R. Van Tassel wrote: I am having an issue with a form, basically an order form, with 10 rows. Each row is the same, the rows are being generated by a loop and I am appending the counter of the loop to the name of the form elements (i.e. quantity1, type1, next row = quantity2, type2, etc) I can't seem to receive the variables without using sessions, which I'm trying not to do. If only the first 2 rows are being filled out and submitted I need to be able to loop through, grab all the variables and print them out. Can anyone give any suggestion? Make them an array: input type=text name=quantity[1] value=X input type=text name=quantity[2] value=X etc etc. Then when you post you get an array of quantities which you can loop through: foreach($_POST['quantity'] as $p = $value) { if (empty($value)) continue; // they didn't fill this field in. } -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Forms
R. Van Tassel wrote: Thanks for the quick response, that seems simple enough, but each row has about 12 fields, so I just create 12 foreach statements? Always CC the list.. Number the fields in the same way and you can do something like this: $number_of_fields = sizeof($_POST['quantity']); for($i = 1; $i = $number_of_fields; $i++) $name = $_POST['name'][$i]; $description = $_POST['description'][$i]; $qty = $_POST['quantity'][$i]; . } and so on. You'll need to add your own checks to make sure the fields are set correctly.. -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 11:05 PM To: R. Van Tassel Cc: php-general@lists.php.net Subject: Re: [PHP] PHP Forms R. Van Tassel wrote: I am having an issue with a form, basically an order form, with 10 rows. Each row is the same, the rows are being generated by a loop and I am appending the counter of the loop to the name of the form elements (i.e. quantity1, type1, next row = quantity2, type2, etc) I can't seem to receive the variables without using sessions, which I'm trying not to do. If only the first 2 rows are being filled out and submitted I need to be able to loop through, grab all the variables and print them out. Can anyone give any suggestion? Make them an array: input type=text name=quantity[1] value=X input type=text name=quantity[2] value=X etc etc. Then when you post you get an array of quantities which you can loop through: foreach($_POST['quantity'] as $p = $value) { if (empty($value)) continue; // they didn't fill this field in. } -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP forms that are valid XHTML
Hello, I'm *very* new to PHP. I am working through the 'Professional PHP Programming' book by Worx. In their forms they use the name attribute (ie. name=example) instead of XHTML's id attribute (ie. id=example). If I use 'name' my results display on the next page after the submit button is pressed, but if I change it 'id' the results do not display. How can I fix this? Thanks Tim Burgan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP forms that are valid XHTML
Hi, Wednesday, December 31, 2003, 11:45:37 AM, you wrote: TB Hello, TB I'm *very* new to PHP. I am working through the 'Professional PHP TB Programming' book by Worx. TB In their forms they use the name attribute (ie. name=example) instead of TB XHTML's id attribute (ie. id=example). TB If I use 'name' my results display on the next page after the submit TB button is pressed, but if I change it 'id' the results do not display. TB How can I fix this? TB Thanks TB Tim Burgan id is used locally on the client and not passed when you press submit, there is nothing wrong with using both if id is needed like input type=text id=test name=test value=/ -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP forms that are valid XHTML
Tim Burgan wrote: In their forms they use the name attribute (ie. name=example) instead of XHTML's id attribute (ie. id=example). How can I fix this? (X)HTML still requires name to be used for forms. It's usually best to use both name and ID for forms. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP forms that are valid XHTML
Thanks for your replies. The name attribute is depreciated in XHTML for use with the input tag and has been replaced with the id attribute. The name element can still be used in the form tag though. What I'm looking for is something similar to ASP's GetElementByID(example); Thanks Tim Burgan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php, forms, mysql
Hello, I could use some help. I have two framed pages, upperframe.html and lowerframe.html. In upper frame.html: echo table border=1; echo trtd/tdtdID/tdtdSubject/tdtdOpen/tdtdClose/td/tr; while($row = MySQL_fetch_array($result)) { echo trtdforminput type=\checkbox\ method=\post\ name=\linia\/form/td; echo tda href=\\ target=\_parent\{$row['id']}/a/td; ?? echo td{$row['subject']}/td; echo td{$row['open']}/td; echo td{$row['close']}/td/tr; } echo /table; I display the content of the main table, which has an autoincrement index. For every index I have another table, something like tableID. What I want is to press on the id from a row in upperframe table and to display in lowerframe the tableID. How can I do that? Thanks a lot, Adrian
Re: [PHP] php, forms, mysql
You don't need to use forms (which you got wrong), but simple links with target=lowerframe and href=lowerframe.php?tableID=$tableID, then you get in your lowerframe.php $_GET['tableID'] Adrian Partenie wrote: Hello, I could use some help. I have two framed pages, upperframe.html and lowerframe.html. In upper frame.html: echo table border=1; echo trtd/tdtdID/tdtdSubject/tdtdOpen/tdtdClose/td/tr; while($row = MySQL_fetch_array($result)) { echo trtdforminput type=\checkbox\ method=\post\ name=\linia\/form/td; echo tda href=\\ target=\_parent\{$row['id']}/a/td; ?? echo td{$row['subject']}/td; echo td{$row['open']}/td; echo td{$row['close']}/td/tr; } echo /table; I display the content of the main table, which has an autoincrement index. For every index I have another table, something like tableID. What I want is to press on the id from a row in upperframe table and to display in lowerframe the tableID. How can I do that? Thanks a lot, Adrian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Forms
Hi I think your mysql_query is wrong. You need to include the $db variable in the query otherwise it doesn't know where to put the stuff. $result = mysql_query($sql, $db); Cheers JD -Original Message- From: Chiew, Richard [mailto:[EMAIL PROTECTED]] Sent: Monday, February 25, 2002 6:31 PM To: [EMAIL PROTECTED] Subject: [PHP] PHP Forms I have the following php code to asks for a new student to fill out a registration form. Using php, take what the user enters and put it into the students table. But when i select * from students in mysql, it didn't show, why? HTML BODY bgColor=#ff ?php if ($submit) { // process form $db = mysql_connect (localhost, root, mollier); $select=mysql_select_db (mydb); $sql = INSERT INTO students (student_id, firstname,lastname, address) VALUES ('$student_id', '$firstname', '$lastname', '$address'); $result = mysql_query($sql); echo Thank you! Information entered.\n; } else{ // display form ? FORM onsubmit=return formvalidation(this) action=?php echo $PHP_SELF? method=postINPUT type=hidden value=New Student Registration - BBS name=FORM_NAME P style=LINE-HEIGHT: 100%; BACKGROUND-COLOR: #ff align=centerBFONT color=#ff size=5BRREGISTRATION FORMBRBR/FONT/B/P PREB FONT color=#ffREQUIRED QUESTIONS:/FONT/B BR 1. What is your student id number?nbsp;INPUT tabIndex=2 maxLength=46 size=46 name=student_idBR 2. What is your name?BR First name:input type=Text name=firstnamebr Last name:input type=Text name=lastnamebr Address: input type=Text name=address size=60BR /PRE UL LI P style=BACKGROUND-COLOR: #fffont color=#FF3300Please click the Submit Button only once/font /P LI P style=BACKGROUND-COLOR: #fffont color=#FF3300Then wait for your confirmation screen/font /P LI P style=BACKGROUND-COLOR: #fffont color=#FF3300Save the confirmation screen because it has information you will need/font /P /LI/UL P style=BACKGROUND-COLOR: #ffINPUT type=submit value=Submit Registrationnbsp;/P P style=BACKGROUND-COLOR: #ff align=centerEnd of Form-Thank You!/P/FORM HR H5 style=BACKGROUND-COLOR: #ff /H5 ?php } // end if ? /BODY/HTML
[PHP] PHP Forms
I have the following php code to asks for a new student to fill out a registration form. Using php, take what the user enters and put it into the students table. But when i select * from students in mysql, it didn't show, why? HTML BODY bgColor=#ff ?php if ($submit) { // process form $db = mysql_connect (localhost, root, mollier); $select=mysql_select_db (mydb); $sql = INSERT INTO students (student_id, firstname,lastname, address) VALUES ('$student_id', '$firstname', '$lastname', '$address'); $result = mysql_query($sql); echo Thank you! Information entered.\n; } else{ // display form ? FORM onsubmit=return formvalidation(this) action=?php echo $PHP_SELF? method=postINPUT type=hidden value=New Student Registration - BBS name=FORM_NAME P style=LINE-HEIGHT: 100%; BACKGROUND-COLOR: #ff align=centerBFONT color=#ff size=5BRREGISTRATION FORMBRBR/FONT/B/P PREB FONT color=#ffREQUIRED QUESTIONS:/FONT/B BR 1. What is your student id number?nbsp;INPUT tabIndex=2 maxLength=46 size=46 name=student_idBR 2. What is your name?BR First name:input type=Text name=firstnamebr Last name:input type=Text name=lastnamebr Address: input type=Text name=address size=60BR /PRE UL LI P style=BACKGROUND-COLOR: #fffont color=#FF3300Please click the Submit Button only once/font /P LI P style=BACKGROUND-COLOR: #fffont color=#FF3300Then wait for your confirmation screen/font /P LI P style=BACKGROUND-COLOR: #fffont color=#FF3300Save the confirmation screen because it has information you will need/font /P /LI/UL P style=BACKGROUND-COLOR: #ffINPUT type=submit value=Submit Registrationnbsp;/P P style=BACKGROUND-COLOR: #ff align=centerEnd of Form-Thank You!/P/FORM HR H5 style=BACKGROUND-COLOR: #ff /H5 ?php } // end if ? /BODY/HTML
Re: [PHP] PHP Forms
On Tuesday 26 February 2002 02:31, Chiew, Richard wrote: I have the following php code to asks for a new student to fill out a registration form. Using php, take what the user enters and put it into the students table. But when i select * from students in mysql, it didn't show, why? HTML BODY bgColor=#ff ?php if ($submit) { // process form $db = mysql_connect (localhost, root, mollier); $select=mysql_select_db (mydb); $sql = INSERT INTO students (student_id, firstname,lastname, address) VALUES ('$student_id', '$firstname', '$lastname', '$address'); $result = mysql_query($sql); echo Thank you! Information entered.\n; Try adding some debug code. Look at the examples in the manual chapter MySQL functions. echo $sql to see what it contains. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* Your picture of the world often changes just before you get it into focus. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Forms
Your submit button does not have name=submit set. So $submit is never being set. Also your html is full of errors, I would clean that up and put it thru a validator, try html tidy (www.w3c.org). And, make sure that formvalidation() is passing true, is that fails the form will never be submitted. -- Stewart On Mon, 25 Feb 2002, Chiew, Richard wrote: I have the following php code to asks for a new student to fill out a registration form. Using php, take what the user enters and put it into the students table. But when i select * from students in mysql, it didn't show, why? HTML BODY bgColor=#ff ?php if ($submit) { // process form $db = mysql_connect (localhost, root, mollier); $select=mysql_select_db (mydb); $sql = INSERT INTO students (student_id, firstname,lastname, address) VALUES ('$student_id', '$firstname', '$lastname', '$address'); $result = mysql_query($sql); echo Thank you! Information entered.\n; } else{ // display form ? FORM onsubmit=return formvalidation(this) action=?php echo $PHP_SELF? method=postINPUT type=hidden value=New Student Registration - BBS name=FORM_NAME P style=LINE-HEIGHT: 100%; BACKGROUND-COLOR: #ff align=centerBFONT color=#ff size=5BRREGISTRATION FORMBRBR/FONT/B/P PREB FONT color=#ffREQUIRED QUESTIONS:/FONT/B BR 1. What is your student id number?nbsp;INPUT tabIndex=2 maxLength=46 size=46 name=student_idBR 2. What is your name?BR First name:input type=Text name=firstnamebr Last name:input type=Text name=lastnamebr Address: input type=Text name=address size=60BR /PRE UL LI P style=BACKGROUND-COLOR: #fffont color=#FF3300Please click the Submit Button only once/font /P LI P style=BACKGROUND-COLOR: #fffont color=#FF3300Then wait for your confirmation screen/font /P LI P style=BACKGROUND-COLOR: #fffont color=#FF3300Save the confirmation screen because it has information you will need/font /P /LI/UL P style=BACKGROUND-COLOR: #ffINPUT type=submit value=Submit Registrationnbsp;/P P style=BACKGROUND-COLOR: #ff align=centerEnd of Form-Thank You!/P/FORM HR H5 style=BACKGROUND-COLOR: #ff /H5 ?php } // end if ? /BODY/HTML -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Forms
Hello, I am new to PHP. I have PHP (cgi version) configured on my machine running XP Pro and IIS. It works fine. The first script I wanted to write was the ever-useful feedback form script where the contents of a form are e-mailed to the webmaster. I am sure that I have a working script but when I test on my machine I get a server error. I realize that this is most likely because I don't have any mail settings configured on IIS (new to this as well). I was wondering if someone could give me some advice on how to properly set this up so I can locally test mail scripts like this. Thanks, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP Forms
Mail() function works fine on win32, you need enter smtp server in your php.ini and sendfrom address. example: SMTP = 10.1.25.1 ; for Win32 only sendmail_from = [EMAIL PROTECTED] Valentin Petruchek (aki Zliy Pes) *** ??? ?? *** http://zliypes.com.ua mailto:[EMAIL PROTECTED] - Original Message - From: Matt Obstgarten [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 02, 2002 3:48 PM Subject: [PHP] PHP Forms Hello, I am new to PHP. I have PHP (cgi version) configured on my machine running XP Pro and IIS. It works fine. The first script I wanted to write was the ever-useful feedback form script where the contents of a form are e-mailed to the webmaster. I am sure that I have a working script but when I test on my machine I get a server error. I realize that this is most likely because I don't have any mail settings configured on IIS (new to this as well). I was wondering if someone could give me some advice on how to properly set this up so I can locally test mail scripts like this. Thanks, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP Forms and String Limitations
I've set up a news database with a PHP front-end and am using MS SQL Server. The news table is set up correctly with the pertinent field being of type 'text' which, according to documentation, should support well over 10 megs of text data. This is the problem: The user tries to submit a news article of 2+ pages (approx 4400 characters) but the article gets truncated to about 4050 characters. Is there some sort of limitation on PHP variables that is causing this? Thanks! Best regards, Jeremy Reed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP forms
Hi, my name is Victor from Namibia, I do web development with PHP, I hapenned to find your email address on one of the PHP sites on the Net, as one of the contributors on the PHP notes. Can you please, if it is possible, tell me how to write in a form field with PHP script. Like in Javascript, if one has a form named members and a text field called memberid, one can write in the memberid field as follows: script language =javascript member.memberid.value='M100'; /script I will appreciate your help very much. Thanking you in advance. Vict -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP forms
e.g. input type=password name=memberid !!NOW!! value=?php echo "whatever"; ? Johannes "Victor Hamutenya" [EMAIL PROTECTED] schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, my name is Victor from Namibia, I do web development with PHP, I hapenned to find your email address on one of the PHP sites on the Net, as one of the contributors on the PHP notes. Can you please, if it is possible, tell me how to write in a form field with PHP script. Like in Javascript, if one has a form named members and a text field called memberid, one can write in the memberid field as follows: script language =javascript member.memberid.value='M100'; /script I will appreciate your help very much. Thanking you in advance. Vict -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]