[PHP] update query not working
I wonder if anyone can see why the following code is not working. this is taken from a larger functions, the rest of which seems to be working well: print INPUT TYPE=\Submit\ NAME=\Submit\ Value=\Update\/td; print td/tdtd/td/tr; print /table; print /form; if ($_POST['Update']) { print updated!!; $rank = $HTTP_POST_VARS['rank']; $title_new = $HTTP_POST_VARS['titles']; $query_update = UPDATE choices_peter SET rank = $rank, workshop_id = $title_new WHERE choice_ID = $choice_id; $update = mysql_query($query_update, $link) or die(display_db_query: . mysql_error()); } I do not see the statement updated!!! printed, but I cannot see anything wrong with my syntax. Any help would be appreciated. Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP_SELF syntax
Could someone tell me why this code prompts a parse error. I have tried it several different way. The statement is called from within a function: print form method=\POST\ name=\update_workshop\ action=\$_SERVER['PHP_SELF']\\n; Many thanks Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variables not being received from form
Thanks to those who have helped me with my two other questions this afternoon. In the function below, the update query at the end is inserting empty values into the database. For some reason the lines: $rank = $HTTP_POST_VARS['rank']; $title_new = $HTTP_POST_VARS['titles']; re not picking up the form values. Here is the complete function. I do not have a form action set so that I can read the SQL message. The update query is working. function retrieve_select_listing($link, $workshop, $session, $username) { $query_retrieve = SELECT choice_ID, rank, workshop_id FROM choices_peter WHERE workshop_ID = '$workshop' AND username ='$username'; $result1 = mysql_query($query_retrieve, $link) or die(display_db_query: . mysql_error()); $row1 = mysql_fetch_array($result1); $choice_id = $row1[0]; $query_title = SELECT title, CONCAT(sessionlet, sesnumber) AS SessionID FROM ECOO2003 WHERE sessionlet = '$session'; $result2 = mysql_query($query_title, $link) or die(display_db_query: . mysql_error()); while ($columns = mysql_fetch_array($result2)) { $column = $columns['title']; $sessionid = $columns['SessionID']; $selected = ; if ($sessionid == $row1['workshop_id']) { $selected = SELECTED; } $title_block .= OPTION name='title' value=\$sessionid\ $selected$column/OPTION\n; } print trtd colspan=\4\; $selected_session = $HTTP_POST_VARS['titles']; print form method=\POST\ name=\update_workshop\ action=\\\n; print Change the rank of this workshop, or select another workshop from this session and click the update button.brbr/td/tr; print trtd colspan=\4\table border=\1\ width=\80%\; print trthworkshop/ththRank/ththWorkshop Title/th/tr; print trtd$row1[2]/tdtdinput type = \text\ name =\rank\ value=$row1[1]/tdtdSELECT NAME=\titles\$title_block/SELECT/td/tr\n; print trtd colspan =\3\; print input type=\hidden\ name=\update_select\ value=\v\; print brAfter you have made your changes, click the Update button to confirm these.br/td/trtrtd; print INPUT TYPE=\Submit\ NAME=\Submit\ Value=\Update\/td; print td/tdtd/td/tr; print /table; print /form; if ($_POST['Submit']=='Update') { print updated!!; $rank = $HTTP_POST_VARS['rank']; $title_new = $HTTP_POST_VARS['titles']; print rank =$rankbr; print title# = $title_newbr; $query_update = UPDATE choices_peter SET rank = '$rank', workshop_id = '$title_new' WHERE choice_ID = '$choice_id'; $update = mysql_query($query_update, $link) or die(display_db_query: . mysql_error()); } } Many thanks Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg usage
Could someone please tell me why this code is not working: ereg ('^[A-H]*([0-9]+)-$', $rank, $matches); $workshop_ID = $matches[1][2}; where $rank is something like C12-1 and I just need the C12 part. Many thanks Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] function problem
I have a function below which populates a select list, based on the query string and the field name. It then prints a string: function populate_selects($query_name, $db_field, $link, $string) { $result = mysql_query($query_name, $link) or die (Could not execute query.); while ($columns = mysql_fetch_array($result)) { $column = $columns[$db_field]; global $option_block; $option_block .= OPTION name='vendor1' value=\$column\$column/OPTION\n; } print $string; } Part of the string that is printed in $string is the $option_block which is in the function. There seems to be some problem with scope here. I made the $option_block variable global but it still won't print. I have tested that the $column field is being populated and it is, so I believe that it must be the $option_block part that isn't working. Does anyone have any suggestions? Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] function problem
Here is the string that is being used in this function example. Everything print except the option_block // Vendor string $vendor_string .= EOVS $header_string tr td colspan=4br br form method=POST name=insert_url action=week6.php?view=vendorq Select the vendor of your choice: SELECT NAME=vendor2 $option_block; /SELECT input type=hidden name=vendor_select value=v INPUT TYPE=Submit NAME=Submit Value=Submit /FORM EOVS; -Original Message- From: Kevin Stone [mailto:[EMAIL PROTECTED]] Sent: Friday, February 14, 2003 6:41 PM To: Php-General Subject: Re: [PHP] function problem Exactly where does $option_block get put into $string? -Kevin - Original Message - From: Peter Gumbrell [EMAIL PROTECTED] To: Php-General [EMAIL PROTECTED] Sent: Friday, February 14, 2003 4:11 PM Subject: [PHP] function problem I have a function below which populates a select list, based on the query string and the field name. It then prints a string: function populate_selects($query_name, $db_field, $link, $string) { $result = mysql_query($query_name, $link) or die (Could not execute query.); while ($columns = mysql_fetch_array($result)) { $column = $columns[$db_field]; global $option_block; $option_block .= OPTION name='vendor1' value=\$column\$column/OPTION\n; } print $string; } Part of the string that is printed in $string is the $option_block which is in the function. There seems to be some problem with scope here. I made the $option_block variable global but it still won't print. I have tested that the $column field is being populated and it is, so I believe that it must be the $option_block part that isn't working. Does anyone have any suggestions? Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with ==?
In the following code $view = $HTTP_GET_VARS[view]; print $view; if ($view == vendor) { code here } print $view produces 'vendor' but the if statement in the next section isn't being triggered. Can anyone see what is wrong here? I have tried double quotes, single quotes and no quotes around 'vendor' but none of them work. Thanks Peter Gumbrell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] selecting from an array based on form content
The following code loops through a multidimensional array, printing the subject heading and then the strand: foreach( $strandx as $subjectx=$strandy ) { print lib.$subjectx./b.br /\n; print ul\n; asort( $strandy ); // sorts the strands foreach( $strandy as $str ) { print li; checkbox(fstrand[],$subjectx,$str,0,0); print /li\n; } print /ul\n; } print /ol\n; This is the array so far: $strandx = array('English' = array('Reading', 'Writing','Oral and Visual Communication'), 'Mathematics' = array('Number Sense and Numeration', 'Measurement', 'Geometry and Spatial Sense','Patterning and Algebra','Data Management and Probability')); I would like to limit the subject and strand being printed based on the subject selected in a form. So, for example, if English is selected in the form, only the subject name and the strands for English would be published. Could someone please help me with the code for this. Many thanks, Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] selecting from an array based on form content
Thanks for the suggestion, John. When I implement your code, however, I get an error saying Warning: Invalid argument supplied for foreach() in home/student/peter/public_html/week4.php on line 153 where line 153 is foreach($strandx[$subject] as $strandy ) This is the code as I have it now: switch($_POST['fsubject']) { case English: $subject = English; break; case Mathematics: $subject = Mathematics; break; } Print h4Now select the strands for Grade $grades: $subject:/h4/td/trtrtd; print td; print $subject; //this tells me that I have the correct value foreach($strandx[$subject] as $strandy ) { //print lib.$subject./b.br /\n; print ul\n; foreach( $strandy as $str ) { print li; checkbox(fstrand[],$strandx,$str,0,0); print /li\n; } Any help would again be appreciated. Peter -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 02, 2003 1:28 PM To: 'Peter Gumbrell'; [EMAIL PROTECTED] Subject: RE: [PHP] selecting from an array based on form content The following code loops through a multidimensional array, printing the subject heading and then the strand: foreach( $strandx as $subjectx=$strandy ) { print lib.$subjectx./b.br /\n; print ul\n; asort( $strandy ); // sorts the strands foreach( $strandy as $str ) { print li; checkbox(fstrand[],$subjectx,$str,0,0); print /li\n; } print /ul\n; } print /ol\n; This is the array so far: $strandx = array('English' = array('Reading', 'Writing','Oral and Visual Communication'), 'Mathematics' = array('Number Sense and Numeration', 'Measurement', 'Geometry and Spatial Sense','Patterning and Algebra','Data Management and Probability')); I would like to limit the subject and strand being printed based on the subject selected in a form. So, for example, if English is selected in the form, only the subject name and the strands for English would be published. Could someone please help me with the code for this. Since you already know $subjectx (English or Math), then just use that value in your foreach() loop... Foreach($strandx[$subjectx] as $strandy) Where $subjectx would come from your form. Provide some validation first. So something like this: //Many ways to do this, just validate //whatever is coming from your form //matches a key in $strandx switch($_POST['subject']) { case English $subject = English break; default: $subject = Mathematics; break; } print ollib.$subject./b.br /\n; foreach( $strandx[$subject] as $strandy ) { print ul\n; asort($strandy ); // sorts the strands foreach( $strandy as $str ) { print li; checkbox(fstrand[],$subjectx,$str,0,0); print /li\n; } print /ul\n; } print /li/ol\n; ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] selecting from an array based on form content
$strandx is defined with code at the top of the page, as follows $strandx = array('English' = array('Reading', 'Writing','Oral and Visual Communication'), 'Mathematics' = array('Number Sense and Numeration', 'Measurement', 'Geometry and Spatial Sense','Patterning and Algebra','Data Management and Probability')); Peter Gumbrell [EMAIL PROTECTED] -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 02, 2003 2:50 PM To: 'Peter Gumbrell'; [EMAIL PROTECTED] Subject: RE: [PHP] selecting from an array based on form content Where do you define the $strandx array? What is it's value? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -Original Message- From: Peter Gumbrell [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 02, 2003 2:08 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] selecting from an array based on form content Thanks for the suggestion, John. When I implement your code, however, I get an error saying Warning: Invalid argument supplied for foreach() in home/student/peter/public_html/week4.php on line 153 where line 153 is foreach($strandx[$subject] as $strandy ) This is the code as I have it now: switch($_POST['fsubject']) { case English: $subject = English; break; case Mathematics: $subject = Mathematics; break; } Print h4Now select the strands for Grade $grades: $subject:/h4/td/trtrtd; print td; print $subject; //this tells me that I have the correct value foreach($strandx[$subject] as $strandy ) { //print lib.$subject./b.br /\n; print ul\n; foreach( $strandy as $str ) { print li; checkbox(fstrand[],$strandx,$str,0,0); print /li\n; } Any help would again be appreciated. Peter -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 02, 2003 1:28 PM To: 'Peter Gumbrell'; [EMAIL PROTECTED] Subject: RE: [PHP] selecting from an array based on form content The following code loops through a multidimensional array, printing the subject heading and then the strand: foreach( $strandx as $subjectx=$strandy ) { print lib.$subjectx./b.br /\n; print ul\n; asort( $strandy ); // sorts the strands foreach( $strandy as $str ) { print li; checkbox(fstrand[],$subjectx,$str,0,0); print /li\n; } print /ul\n; } print /ol\n; This is the array so far: $strandx = array('English' = array('Reading', 'Writing','Oral and Visual Communication'), 'Mathematics' = array('Number Sense and Numeration', 'Measurement', 'Geometry and Spatial Sense','Patterning and Algebra','Data Management and Probability')); I would like to limit the subject and strand being printed based on the subject selected in a form. So, for example, if English is selected in the form, only the subject name and the strands for English would be published. Could someone please help me with the code for this. Since you already know $subjectx (English or Math), then just use that value in your foreach() loop... Foreach($strandx[$subjectx] as $strandy) Where $subjectx would come from your form. Provide some validation first. So something like this: //Many ways to do this, just validate //whatever is coming from your form //matches a key in $strandx switch($_POST['subject']) { case English $subject = English break; default: $subject = Mathematics; break; } print ollib.$subject./b.br /\n; foreach( $strandx[$subject] as $strandy ) { print ul\n; asort($strandy ); // sorts the strands foreach( $strandy as $str ) { print li; checkbox(fstrand[],$subjectx,$str,0,0); print /li\n; } print /ul\n; } print /li/ol\n; ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] select unique values from an array
I am attempting to populate form elements from a text file which has been read and split into arrays. Some of the items are repeated many times: grade level, for example. Is there a way of just selecting unique values so that each value is displayed only once in the check boxes or radio buttons? Many thanks Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] selecting items from an array
I have a text file which is read into an array $data using fgets(). The data is then split into further arrays by tab delimiter. I would like to find a way of extracting and printing items from $data using a form. The form fields (e.g. grade, subject) are populated from the arrays. When the user selects a subject and grade, then clicks the button, I would like to select and print only the data, in this case from the array $expect, where the grade is $grade_selected and the subject is $subject_selected. I would appreciate help with how to select and print the relevant data. Many thanks, Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php