[PHP-DB] Arrays from forms....
I have a problem. I have done this before, but can't find the files. I am using the following function to upload files from a form. foreach ($_FILES[pictures][error] as $key = $error) { if ($error == UPLOAD_ERR_OK) { echo $error_codes[$error]; move_uploaded_file( $_FILES[pictures][tmp_name][$key], images/ .$_FILES[pictures][name][$key] ) or die(Problems with upload); } } I also need to insert the filenames of the uploaded files into a database. There are three fields in my db for these filenames, image1 image2 and image3. What would be the best way to get those filenames from the array into the vars $image1 $image2 and $image3? the first file in the array should be $image1 and so on. Thanks in advance. smime.p7s Description: S/MIME cryptographic signature
Re: [PHP-DB] Arrays from forms....
Gary E. Terry wrote: I have a problem. I have done this before, but can't find the files. I am using the following function to upload files from a form. foreach ($_FILES[pictures][error] as $key = $error) { if ($error == UPLOAD_ERR_OK) { echo $error_codes[$error]; move_uploaded_file( $_FILES[pictures][tmp_name][$key], images/ .$_FILES[pictures][name][$key] ) or die(Problems with upload); } } I also need to insert the filenames of the uploaded files into a database. There are three fields in my db for these filenames, image1 image2 and image3. What would be the best way to get those filenames from the array into the vars $image1 $image2 and $image3? You want variable variables: http://www.php.net/manual/en/language.variables.variable.php ?php for ($i = 1; $i 5; $i++) { ${image.$i} = i is . $i; } echo $image4 . \n; ? i is 4 so after the or die: ${image.$key} = $_FILES['pictures']['name']; -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Arrays from forms....
Gary E. Terry wrote: I don't know if we are on the same page here... Maybe we are and I am just an idiot. The fields in my db are image1 image2 and image3. There are only three fields in the form that is being passed to the php script. But, on the form they are named pictures[]. Here is the full php I am using to process the form output: ?php include db.inc.back.php; foreach ($_FILES[pictures][error] as $key = $error) { if ($error == UPLOAD_ERR_OK) { echo $error_codes[$error]; move_uploaded_file( $_FILES[pictures][tmp_name][$key], bikeimages/ .$_FILES[pictures][name][$key] ) or die(Problems with upload); ${image.$key} = $_FILES['pictures']['name']; } } $make = $_POST['make']; $model = $_POST['model']; $year = $_POST['year']; $color = $_POST['color']; $description = $_POST['description']; $status = $_POST['status']; $query = INSERT INTO `inventory` (`make`, `model`, `year`, `color`, `description`, `image1`, `image2`, `image3`, `status`) VALUES ('$make', '$model', '$year', '$color', '$description', '$image1', '$image2', '$image3', '$status');; $result = mysql_db_query($db, $query) or displayErrorQuery ($query); echo meta http-equiv='refresh' content='0;URL=inventorylist.php'; ? $image1 $image2 and $image3 are not getting defined... Not real sure what's going on. Always cc the list so others can learn or suggest things. Are you uploading 3 images? Maybe define them first as well: foreach ($_FILES .. ) { ${image.$key} = ; if ($error == or do you mean the values are always empty? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Arrays from forms....
Sorry about that, not CC'ing the list... the values are not always empty, they should always have something in them... There should be 3 images uploading. But, I am sure just to make life interesting, there will be times when there could be as little as one uploaded. -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Thursday, November 30, 2006 10:10 PM To: Gary E. Terry Cc: PHP DB Subject: Re: [PHP-DB] Arrays from forms Gary E. Terry wrote: I don't know if we are on the same page here... Maybe we are and I am just an idiot. The fields in my db are image1 image2 and image3. There are only three fields in the form that is being passed to the php script. But, on the form they are named pictures[]. Here is the full php I am using to process the form output: ?php include db.inc.back.php; foreach ($_FILES[pictures][error] as $key = $error) { if ($error == UPLOAD_ERR_OK) { echo $error_codes[$error]; move_uploaded_file( $_FILES[pictures][tmp_name][$key], bikeimages/ .$_FILES[pictures][name][$key] ) or die(Problems with upload); ${image.$key} = $_FILES['pictures']['name']; } } $make = $_POST['make']; $model = $_POST['model']; $year = $_POST['year']; $color = $_POST['color']; $description = $_POST['description']; $status = $_POST['status']; $query = INSERT INTO `inventory` (`make`, `model`, `year`, `color`, `description`, `image1`, `image2`, `image3`, `status`) VALUES ('$make', '$model', '$year', '$color', '$description', '$image1', '$image2', '$image3', '$status');; $result = mysql_db_query($db, $query) or displayErrorQuery ($query); echo meta http-equiv='refresh' content='0;URL=inventorylist.php'; ? $image1 $image2 and $image3 are not getting defined... Not real sure what's going on. Always cc the list so others can learn or suggest things. Are you uploading 3 images? Maybe define them first as well: foreach ($_FILES .. ) { ${image.$key} = ; if ($error == or do you mean the values are always empty? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php smime.p7s Description: S/MIME cryptographic signature
Re: [PHP-DB] Arrays from forms....
Gary E. Terry wrote: Sorry about that, not CC'ing the list... the values are not always empty, they should always have something in them... There should be 3 images uploading. But, I am sure just to make life interesting, there will be times when there could be as little as one uploaded. If you print them out what's in them? echo $image1; echo $image2; I just realized that the $key probably starts at 0 instead of 1, so you might need to check that and then possibly: ${image.($key+1)} = $_FILES['pictures']['name']; -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Arrays from forms....
If I print them, there's nothing. all three Here is the same file, in test mode... ?php include db.inc.back.php; foreach ($_FILES[pictures][error] as $key = $error) { if ($error == UPLOAD_ERR_OK) { echo $error_codes[$error]; move_uploaded_file( $_FILES[pictures][tmp_name][$key], bikeimages/ .$_FILES[pictures][name][$key] ) or die(Problems with upload); ${image.$key} = $_FILES['pictures']['name']; } } $make = $_POST['make']; $model = $_POST['model']; $year = $_POST['year']; $color = $_POST['color']; $description = $_POST['description']; //$image1 = $_POST['image1']; //$image2 = $_POST['image2']; //$image3 = $_POST['image3']; $status = $_POST['status']; echo $image1 -- $image2 -- $image3; /* $query = INSERT INTO `inventory` (`make`, `model`, `year`, `color`, `description`, `image1`, `image2`, `image3`, `status`) VALUES ('$make', '$model', '$year', '$color', '$description', '$image1', '$image2', '$image3', '$status');; $result = mysql_db_query($db, $query) or displayErrorQuery ($query); echo meta http-equiv='refresh' content='0;URL=inventorylist.php'; exit; */ ? I get -- -- outputted. -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Thursday, November 30, 2006 10:39 PM To: Gary E. Terry Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Arrays from forms Gary E. Terry wrote: Sorry about that, not CC'ing the list... the values are not always empty, they should always have something in them... There should be 3 images uploading. But, I am sure just to make life interesting, there will be times when there could be as little as one uploaded. If you print them out what's in them? echo $image1; echo $image2; I just realized that the $key probably starts at 0 instead of 1, so you might need to check that and then possibly: ${image.($key+1)} = $_FILES['pictures']['name']; -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php smime.p7s Description: S/MIME cryptographic signature
Re: [PHP-DB] Arrays from forms....
Gary E. Terry wrote: If I print them, there's nothing. all three Here is the same file, in test mode... ?php include db.inc.back.php; foreach ($_FILES[pictures][error] as $key = $error) { if ($error == UPLOAD_ERR_OK) { echo $error_codes[$error]; move_uploaded_file( $_FILES[pictures][tmp_name][$key], bikeimages/ .$_FILES[pictures][name][$key] ) or die(Problems with upload); ${image.$key} = $_FILES['pictures']['name']; } } Hmm, looks ok. If you: print_r($_FILES[pictures]); and print_r($_FILES[pictures]['error']); do you get stuff there ? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Arrays from forms....
Nope... here is the output. -- -- Array ( [error] = ) -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Thursday, November 30, 2006 10:56 PM To: Gary E. Terry Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Arrays from forms Gary E. Terry wrote: If I print them, there's nothing. all three Here is the same file, in test mode... ?php include db.inc.back.php; foreach ($_FILES[pictures][error] as $key = $error) { if ($error == UPLOAD_ERR_OK) { echo $error_codes[$error]; move_uploaded_file( $_FILES[pictures][tmp_name][$key], bikeimages/ .$_FILES[pictures][name][$key] ) or die(Problems with upload); ${image.$key} = $_FILES['pictures']['name']; } } Hmm, looks ok. If you: print_r($_FILES[pictures]); and print_r($_FILES[pictures]['error']); do you get stuff there ? -- Postgresql php tutorials http://www.designmagick.com/ smime.p7s Description: S/MIME cryptographic signature
Re: [PHP-DB] Arrays from forms....
Gary E. Terry wrote: Nope... here is the output. -- -- Array ( [error] = ) So files aren't being uploaded properly at all. Does your form have: enctype=multipart/form-data in the form header? ie form name='blah' action='form2.php' enctype=multipart/form-data Are your picture fields files? Upload file: input type=file name=pictures[] -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Arrays from forms....
OK.. I am a moron.. Forgot that I had changed the name of the field in the form, and got sidetracked and didn't change it in the php... But, still not working correctly. Here is the output: Array -- Array -- Array from: ?php include db.inc.back.php; foreach ($_FILES[pictures][error] as $key = $error) { if ($error == UPLOAD_ERR_OK) { echo $error_codes[$error]; move_uploaded_file( $_FILES[pictures][tmp_name][$key], bikeimages/ .$_FILES[pictures][name][$key] ) or die(Problems with upload); ${image.($key+1)} = $_FILES['pictures']['name']; } } $make = $_POST['make']; $model = $_POST['model']; $year = $_POST['year']; $color = $_POST['color']; $description = $_POST['description']; //$image1 = $_POST['image1']; //$image2 = $_POST['image2']; //$image3 = $_POST['image3']; $status = $_POST['status']; echo $image1 -- $image2 -- $image3; /* $query = INSERT INTO `inventory` (`make`, `model`, `year`, `color`, `description`, `image1`, `image2`, `image3`, `status`) VALUES ('$make', '$model', '$year', '$color', '$description', '$image1', '$image2', '$image3', '$status');; $result = mysql_db_query($db, $query) or displayErrorQuery ($query); echo meta http-equiv='refresh' content='0;URL=inventorylist.php'; exit; */ ? smime.p7s Description: S/MIME cryptographic signature
Re: [PHP-DB] Arrays from forms....
Gary E. Terry wrote: OK.. I am a moron.. Forgot that I had changed the name of the field in the form, and got sidetracked and didn't change it in the php... But, still not working correctly. Here is the output: Array -- Array -- Array Oops this: ${image.($key+1)} = $_FILES['pictures']['name']; should be: ${image.($key+1)} = $_FILES['pictures'][$key]['name']; -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Arrays from forms....
I know you really meant : ${image.($key+1)} = $_FILES['pictures']['name'][$key]; And it works!!! Thanks oh so very much! -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Thursday, November 30, 2006 11:46 PM To: Gary E. Terry Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Arrays from forms Gary E. Terry wrote: OK.. I am a moron.. Forgot that I had changed the name of the field in the form, and got sidetracked and didn't change it in the php... But, still not working correctly. Here is the output: Array -- Array -- Array Oops this: ${image.($key+1)} = $_FILES['pictures']['name']; should be: ${image.($key+1)} = $_FILES['pictures'][$key]['name']; -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php smime.p7s Description: S/MIME cryptographic signature
Re: [PHP-DB] Arrays from forms....
Gary E. Terry wrote: I know you really meant : ${image.($key+1)} = $_FILES['pictures']['name'][$key]; Oh yeh ;) Glad we got there in the end! :) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Arrays and forms
Hello list, I submitted this problem earlier but got no response so I thought I'd elaborate. The code below successfully displays all of the problems from the db. Based on what is chosen here, needs to go into another table in the db along with a customer tracking id. for($knt = 0;$row = mysql_fetch_row($res3); $knt++) { $cat_detail = $row[0]; echo trtdinput type=\checkbox\ name=\prob[]\ value = \$cat_detail\/td td $cat_detail /td .td High input type=\checkbox\ name=\level[]\ value=\1\/td .td Med input type=\checkbox\ name=\level[]\ value=\2\/td .td Low input type=\checkbox\ name=\level[]\ value=\3\/td .tdcenterinput type=\checkbox\ name=\yes\ Yes /center/td/tr; } When this page is submitted, I can successfully capture $prob[] - but I am having no luck in pulling the corresponding $level[] (if one was checked). So my form - once submitted - may look like: Problem one (no priority picked) Problem two High priority Problem three Low priority My $prob[] would be:My $level[] would be: $prob[0]: Problem one $level[0]: High $prob[1]: Problem two $level[1]: Low $prob[2]: Problem three So as you can see my second problem does not correctly correspond to the correct priority. The first (or all) element(s) in the level array may be null. I have read up on and tried some associative arrays but no luck in utilizing them within a form; been trying all sorts of testing, books, web tuts, etc. but still come up with the same problem. Also in case anyone were to suggest sessions, my supervisor is adamently opposed to using them on this site, not sure why, not even sure if that would make my life easier or not since I've never used them. Any comments (good, bad, indifferent) here would be most appreciated. Any suggestions as to other ways of doing this also appreciated. Many thanks Mignon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Arrays and forms
On Wednesday 15 January 2003 03:23, Mignon Hunter wrote: Hello list, I submitted this problem earlier but got no response so I thought I'd elaborate. The code below successfully displays all of the problems from the db. Based on what is chosen here, needs to go into another table in the db along with a customer tracking id. for($knt = 0;$row = mysql_fetch_row($res3); $knt++) { $cat_detail = $row[0]; echo trtdinput type=\checkbox\ name=\prob[]\ value = \$cat_detail\/td td $cat_detail /td .td High input type=\checkbox\ name=\level[]\ value=\1\/td .td Med input type=\checkbox\ name=\level[]\ value=\2\/td .td Low input type=\checkbox\ name=\level[]\ value=\3\/td .tdcenterinput type=\checkbox\ name=\yes\ Yes /center/td/tr; } When this page is submitted, I can successfully capture $prob[] - but I am having no luck in pulling the corresponding $level[] (if one was checked). So my form - once submitted - may look like: Problem one (no priority picked) Problem two High priority Problem three Low priority My $prob[] would be: My $level[] would be: $prob[0]: Problem one $level[0]: High $prob[1]: Problem two $level[1]: Low $prob[2]: Problem three So as you can see my second problem does not correctly correspond to the correct priority. The first (or all) element(s) in the level array may be null. The reason is that: 1) unchecked checkboxes do not make it into php 2) because you're not specifying an index for the array (level[]), php will create it for you automatically So instead of using just name=level[] specify the level explicitly: name=level[0], name=level[1], etc NB you should do the same for prob[] as well. Having done that then in your example you should get something like: $prob[0]: Problem one $prob[1]: Problem two $level[1]: High $prob[2]: Problem three$level[2]: Low NB that $level[0] is undefined. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Harp not on that string. -- William Shakespeare, Henry VI */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] arrays
Hi everyone, I have a problem sorting my data, I have an array with a flush of values and years from a mysql database. When i have all the values i need php to only print the values, and then group it by year souch that if i had an array that looked like this: Array([2002] = 20,[2002] = 40,[2003] = 93) Then it would print 2002 = 60 2003 = 93 Thanks a lot Best regards, Martin A Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Arrays again
Hi everyone, I need a little help again I have a array with 4 values: 320 - 570 - 860 - 960 Each time it extracts one value it's supposed to take minus it with the old value. So that the output for the array above would be: 320 - 250 - 290 - 100 I hope you get the point and you're able to help me... FIRST im a totally jerk to ARRAYS THANKS !!! Regards Martin Allan Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Arrays again again
Sorry fellers Allready figured it outsorrynow i see that the question was foolish Anyway now i need help with something else... I now have some values: 320 - 250 - 290 - 100 And years that fits to them: 2002 - 2003 - 2004 - 2005 How can i put these dynamic values in a array. be carefull cause i need the array to be filled active in a loop, so i CAN only define ONE year, and ONE value in each LOOP! THANKS!!! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Arrays again again
Perhaps I don't understand what it is you're looking for, but... $a = array(); for ($i = 0; $i $maxvalue; $i++) { $a[$year] = $value; } but this is almost too simple, which probably just means I didn't quite understand your question. Marco -- php|architect - The magazine for PHP Professionals The monthly worldwide magazine dedicated to PHP programmers Come visit us at http://www.phparch.com! On Wed, 2002-11-13 at 19:28, Martin Allan Jensen wrote: Sorry fellers Allready figured it outsorrynow i see that the question was foolish Anyway now i need help with something else... I now have some values: 320 - 250 - 290 - 100 And years that fits to them: 2002 - 2003 - 2004 - 2005 How can i put these dynamic values in a array. be carefull cause i need the array to be filled active in a loop, so i CAN only define ONE year, and ONE value in each LOOP! THANKS!!! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Arrays again again
The problem there is that you've got $a[$year] getting set a bunch of times. That is busted code. $a[$year] will only contain the LAST value. Replace that line with this one. $a[] = array(year=$year, value=$value); OR $a[$i] = array(year=$year, value=$value); Now $a[0][year] = 2002 Now $a[0][value] = 320 And on and on. Peter On 13 Nov 2002, Marco Tabini wrote: Perhaps I don't understand what it is you're looking for, but... $a = array(); for ($i = 0; $i $maxvalue; $i++) { $a[$year] = $value; } but this is almost too simple, which probably just means I didn't quite understand your question. Marco -- php|architect - The magazine for PHP Professionals The monthly worldwide magazine dedicated to PHP programmers Come visit us at http://www.phparch.com! On Wed, 2002-11-13 at 19:28, Martin Allan Jensen wrote: Sorry fellers Allready figured it outsorrynow i see that the question was foolish Anyway now i need help with something else... I now have some values: 320 - 250 - 290 - 100 And years that fits to them: 2002 - 2003 - 2004 - 2005 How can i put these dynamic values in a array. be carefull cause i need the array to be filled active in a loop, so i CAN only define ONE year, and ONE value in each LOOP! THANKS!!! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] arrays db
Okey people, i try again!! I have a table in a mysql database that holds this: +++++--+ | id | maaler | aflaest| vaerdi | pris | +++++--+ | 21 | 11 | 2002-01-01 | 15160 | 0.00 | | 22 | 11 | 2002-02-01 | 15180 | 0.00 | | 23 | 11 | 2002-03-01 | 15200 | 0.00 | | 24 | 11 | 2002-04-01 | 15240 | 0.00 | | 25 | 11 | 2002-05-01 | 15250 | 0.00 | | 27 | 10 | 2002-11-14 |210 | 0.00 | | 30 | 10 | 2002-12-19 |230 | 0.00 | +++++--+ Each maaler have it's own start registration witch is: ++--+---+ | id | nummer | start | ++--+---+ | 10 | 56456| 200 | | 11 | 02 | 15150 | ++--+---+ I then made a script that takes start for each maaler if it have any registrations. Then it does this: if its first field then it takes the vaerdi(THE VALUE) and - it with the start (THE STARTREGISTRATION) For the next fields it takes the vaerdi - the last vaerdi. My problem is that after the script has ran it have lets say 20 yeas 2002 (the registration year called aflaest in the table) and lets say two 2003. I only need ONE value vaerdi per year, witch is the one it just calculated in a loop. But it have all the values and years in the array. How do i only take ONE value per year in PHP NOT SQL?? I really hope this is discriping enough!! THANKS ALL! Martin Allan Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] arrays db
Why don't you want to do this with SQL? Ignatius - Original Message - From: Martin Allan Jensen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 11, 2002 2:48 PM Subject: [PHP-DB] arrays db Okey people, i try again!! I have a table in a mysql database that holds this: +++++--+ | id | maaler | aflaest| vaerdi | pris | +++++--+ | 21 | 11 | 2002-01-01 | 15160 | 0.00 | | 22 | 11 | 2002-02-01 | 15180 | 0.00 | | 23 | 11 | 2002-03-01 | 15200 | 0.00 | | 24 | 11 | 2002-04-01 | 15240 | 0.00 | | 25 | 11 | 2002-05-01 | 15250 | 0.00 | | 27 | 10 | 2002-11-14 |210 | 0.00 | | 30 | 10 | 2002-12-19 |230 | 0.00 | +++++--+ Each maaler have it's own start registration witch is: ++--+---+ | id | nummer | start | ++--+---+ | 10 | 56456| 200 | | 11 | 02 | 15150 | ++--+---+ I then made a script that takes start for each maaler if it have any registrations. Then it does this: if its first field then it takes the vaerdi(THE VALUE) and - it with the start (THE STARTREGISTRATION) For the next fields it takes the vaerdi - the last vaerdi. My problem is that after the script has ran it have lets say 20 yeas 2002 (the registration year called aflaest in the table) and lets say two 2003. I only need ONE value vaerdi per year, witch is the one it just calculated in a loop. But it have all the values and years in the array. How do i only take ONE value per year in PHP NOT SQL?? I really hope this is discriping enough!! THANKS ALL! Martin Allan Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] arrays db
On Monday 11 November 2002 21:48, Martin Allan Jensen wrote: Okey people, i try again!! I have a table in a mysql database that holds this: +++++--+ | id | maaler | aflaest| vaerdi | pris | +++++--+ | 21 | 11 | 2002-01-01 | 15160 | 0.00 | | 22 | 11 | 2002-02-01 | 15180 | 0.00 | | 23 | 11 | 2002-03-01 | 15200 | 0.00 | | 24 | 11 | 2002-04-01 | 15240 | 0.00 | | 25 | 11 | 2002-05-01 | 15250 | 0.00 | | 27 | 10 | 2002-11-14 |210 | 0.00 | | 30 | 10 | 2002-12-19 |230 | 0.00 | +++++--+ Each maaler have it's own start registration witch is: ++--+---+ | id | nummer | start | ++--+---+ | 10 | 56456| 200 | | 11 | 02 | 15150 | ++--+---+ I still don't understand what you're doing :-/ I then made a script that takes start for each maaler if it have any registrations. Then it does this: if its first field then it takes the vaerdi(THE VALUE) and - it with the start (THE STARTREGISTRATION) For the next fields it takes the vaerdi - the last vaerdi. My problem is that after the script has ran it have lets say 20 yeas 2002 (the registration year called aflaest in the table) and lets say two 2003. But why are you keeping all those transient values ... I only need ONE value vaerdi per year, witch is the one it just calculated ... why don't you just keep the 'latest' value -- which should be the maximum value? in a loop. But it have all the values and years in the array. How do i only take ONE value per year in PHP NOT SQL?? I really hope this is discriping enough!! -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* A lot of people are afraid of heights. Not me. I'm afraid of widths. -- Steven Wright */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] arrays, variables, and register_globals
I developed my site on a server where register_globals was off; now I'm putting the site up on a server where they are on. I know how to echo the value of a variable that is passed in the querystring, but I'm having trouble echoing the value of a variable that is in my select statement--I can get the value when it is in a while loop, but outside of that I'm having trouble: $query = Select blah1, blah2, blah3 from blahtable; $result = mysql_query ($query) or die (Cannot complete query); print $row[1]; // this is the kind of thing that is not working...I tried get_defined_vars() but may not have used it correctly while ($row = mysql_fetch_row ($result)) { print $row[1], $row[2], etc.); } ? In the above example, the variables in the while loop get expanded, but the one outside doesn't Can anyone help? thanks in advance, Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Arrays
On Friday 31 May 2002 03:53, Morten Nielsen wrote: Hi, I need to store a lot of vaiables (75+) in a MySQL database. What is the best way to do this? Should I create a field for each variable in the database or is it possible to create an array for a series of variables? You can put everything in a single array then serialize() it and store (in a single field). -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* If he had only learnt a little less, how infinitely better he might have taught much more! */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Arrays
I am trying to insert event dats into a database and to make sure the user puts the date in the correct format. I am now trying to collect the information from the three fields and insert it into one field. code as follows: $eventdate = array (eventyear, eventmonth, eventday); when I insert it into the database like: $query = INSERT INTO $tablename4 VALUES ('0', '$entername', '$date', '$eventdate', '$eventheading', '$eventbody' ); for the $eventdate variable the word array is inserted. Could someone please tell me where I am going wrong. -- Alex Francis Cameron Design 35, Drumillan Hill Greenock PA16 0XD Tel 01475 798106 [EMAIL PROTECTED] http://www.camerondesign.co.uk This message is sent in confidence for the addressee only. It may contain legally privileged information. Unauthorised recipients are requested to preserve this confidentiality and to advise the sender immediately of any error in transmission. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Arrays
Your $eventdate variable is an array, not a string so you can't just drop it into an sql query string like that. If you have separate fields in the db for year, month and day then you probably want something like: $query = insert into ... values ( ... , '$eventdate[0]', '$eventdate[1]', '$eventdate[2]', ...); Otherwise, if they're all supposed to go into the same field then do something like: $eventdatestring = join(-, $eventdate); $query = insert into ... values ( ..., '$eventdatestring', ...); This should insert the date in the form eventyear-eventmonth-eventday; -Steve On Monday, April 15, 2002, at 03:13 PM, Alex Francis wrote: I am trying to insert event dats into a database and to make sure the user puts the date in the correct format. I am now trying to collect the information from the three fields and insert it into one field. code as follows: $eventdate = array (eventyear, eventmonth, eventday); when I insert it into the database like: $query = INSERT INTO $tablename4 VALUES ('0', '$entername', '$date', '$eventdate', '$eventheading', '$eventbody' ); for the $eventdate variable the word array is inserted. Could someone please tell me where I am going wrong. -- Alex Francis Cameron Design 35, Drumillan Hill Greenock PA16 0XD Tel 01475 798106 [EMAIL PROTECTED] http://www.camerondesign.co.uk This message is sent in confidence for the addressee only. It may contain legally privileged information. Unauthorised recipients are requested to preserve this confidentiality and to advise the sender immediately of any error in transmission. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Arrays
Got it now, Thank you -- Alex Francis Cameron Design 35, Drumillan Hill Greenock PA16 0XD Tel 01475 798106 [EMAIL PROTECTED] http://www.camerondesign.co.uk This message is sent in confidence for the addressee only. It may contain legally privileged information. Unauthorised recipients are requested to preserve this confidentiality and to advise the sender immediately of any error in transmission. Steve Cayford [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Your $eventdate variable is an array, not a string so you can't just drop it into an sql query string like that. If you have separate fields in the db for year, month and day then you probably want something like: $query = insert into ... values ( ... , '$eventdate[0]', '$eventdate[1]', '$eventdate[2]', ...); Otherwise, if they're all supposed to go into the same field then do something like: $eventdatestring = join(-, $eventdate); $query = insert into ... values ( ..., '$eventdatestring', ...); This should insert the date in the form eventyear-eventmonth-eventday; -Steve On Monday, April 15, 2002, at 03:13 PM, Alex Francis wrote: I am trying to insert event dats into a database and to make sure the user puts the date in the correct format. I am now trying to collect the information from the three fields and insert it into one field. code as follows: $eventdate = array (eventyear, eventmonth, eventday); when I insert it into the database like: $query = INSERT INTO $tablename4 VALUES ('0', '$entername', '$date', '$eventdate', '$eventheading', '$eventbody' ); for the $eventdate variable the word array is inserted. Could someone please tell me where I am going wrong. -- Alex Francis Cameron Design 35, Drumillan Hill Greenock PA16 0XD Tel 01475 798106 [EMAIL PROTECTED] http://www.camerondesign.co.uk This message is sent in confidence for the addressee only. It may contain legally privileged information. Unauthorised recipients are requested to preserve this confidentiality and to advise the sender immediately of any error in transmission. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] arrays and email
I'm working on an application that will allow someone to view all attendees for a specific webinar that my company is hosting. I want to allow the user to send one group email to all participants scheduled for that particular webinar. After I connect to my database my code looks like this: ? $sql = select * from webusers where webdate=\$webdate\; $result = mysql_query($sql) or die(couldn't generate a list of the users); while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[] = $email; } echo form method=\post\ action=\doemailattendees.php\\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0 class=\orange4\\n; echo tr\n; echo td valign=\top\pbTo:/b/p/td\n; echo td valign=\top\p\n; foreach ($list as $value) { print $value, ; $to = $value; } echo /p/td\n; echo /tr\n; echo /table\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0\n; echo tr\n; echo td valign=\top\pbSubject:/b/p/td\n; echo td valign=\top\pinput type=\text\ name=\subject\/p/td\n; echo /tr\n; echo tr\n; echo td valign=\top\pbMessage:/b/p/td\n; echo td valign=\top\textarea name=\message\/textarea/td\n; echo /tr\n; echo tr\n; echo td colspan=2 valign=\top\input type=\submit\ value=\submit\/td\n; echo /tr\n; echo /table\n; echo /form\n; ? The $to, $subject, $message variables then get sent to a page that actually mails the message. The problem I'm having is that it's only being sent to the last person in the array. I understand why this is happening but don't know enough about arrays to find a solution. As my code shows I ambitiously tried setting $to to the entire array but that doesn't work. If anyone would be kind enough to help me out I'd greatly appreciate it. Thank you. Kevin www.worktiviti.com -- PHP Database 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-DB] arrays and email
Hi kevin, Seems like in your while loop, you are not populating your list array correctly with all the emails you have. Try to have a count value and populate the array list accordingly such as: $count = 0; while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[$count] = $email; $count = $count + 1; } Hope this helps. Gurhan -Original Message- From: Kevin Ruiz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:14 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] arrays and email I'm working on an application that will allow someone to view all attendees for a specific webinar that my company is hosting. I want to allow the user to send one group email to all participants scheduled for that particular webinar. After I connect to my database my code looks like this: ? $sql = select * from webusers where webdate=\$webdate\; $result = mysql_query($sql) or die(couldn't generate a list of the users); while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[] = $email; } echo form method=\post\ action=\doemailattendees.php\\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0 class=\orange4\\n; echo tr\n; echo td valign=\top\pbTo:/b/p/td\n; echo td valign=\top\p\n; foreach ($list as $value) { print $value, ; $to = $value; } echo /p/td\n; echo /tr\n; echo /table\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0\n; echo tr\n; echo td valign=\top\pbSubject:/b/p/td\n; echo td valign=\top\pinput type=\text\ name=\subject\/p/td\n; echo /tr\n; echo tr\n; echo td valign=\top\pbMessage:/b/p/td\n; echo td valign=\top\textarea name=\message\/textarea/td\n; echo /tr\n; echo tr\n; echo td colspan=2 valign=\top\input type=\submit\ value=\submit\/td\n; echo /tr\n; echo /table\n; echo /form\n; ? The $to, $subject, $message variables then get sent to a page that actually mails the message. The problem I'm having is that it's only being sent to the last person in the array. I understand why this is happening but don't know enough about arrays to find a solution. As my code shows I ambitiously tried setting $to to the entire array but that doesn't work. If anyone would be kind enough to help me out I'd greatly appreciate it. Thank you. Kevin www.worktiviti.com -- PHP Database 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 Database 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-DB] arrays and email
The other thing you could do is populate a string of emails and add the BCC header to your mail() function. This way everyone's email will not be seen by all other recipients. Check out the docs at www.php.net for this one a better way to build the string would probably be: while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email_list .= $row[12]; } Then just pass $email_list in the BCC - be careful as some ISP's do not allow mass mailings to be sent in BCC. [i.e. mine is limited to 99 emails and then it gets spam blocked so i must send through the mailing list feature] olinux --- Gurhan Ozen [EMAIL PROTECTED] wrote: Hi kevin, Seems like in your while loop, you are not populating your list array correctly with all the emails you have. Try to have a count value and populate the array list accordingly such as: $count = 0; while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[$count] = $email; $count = $count + 1; } Hope this helps. Gurhan -Original Message- From: Kevin Ruiz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:14 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] arrays and email I'm working on an application that will allow someone to view all attendees for a specific webinar that my company is hosting. I want to allow the user to send one group email to all participants scheduled for that particular webinar. After I connect to my database my code looks like this: ? $sql = select * from webusers where webdate=\$webdate\; $result = mysql_query($sql) or die(couldn't generate a list of the users); while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[] = $email; } echo form method=\post\ action=\doemailattendees.php\\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0 class=\orange4\\n; echo tr\n; echo td valign=\top\pbTo:/b/p/td\n; echo td valign=\top\p\n; foreach ($list as $value) { print $value, ; $to = $value; } echo /p/td\n; echo /tr\n; echo /table\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0\n; echo tr\n; echo td valign=\top\pbSubject:/b/p/td\n; echo td valign=\top\pinput type=\text\ name=\subject\/p/td\n; echo /tr\n; echo tr\n; echo td valign=\top\pbMessage:/b/p/td\n; echo td valign=\top\textarea name=\message\/textarea/td\n; echo /tr\n; echo tr\n; echo td colspan=2 valign=\top\input type=\submit\ value=\submit\/td\n; echo /tr\n; echo /table\n; echo /form\n; ? The $to, $subject, $message variables then get sent to a page that actually mails the message. The problem I'm having is that it's only being sent to the last person in the array. I understand why this is happening but don't know enough about arrays to find a solution. As my code shows I ambitiously tried setting $to to the entire array but that doesn't work. If anyone would be kind enough to help me out I'd greatly appreciate it. Thank you. Kevin www.worktiviti.com -- PHP Database 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 Database 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] __ Do You Yahoo!? Great stuff seeking new owners in Yahoo! Auctions! http://auctions.yahoo.com -- PHP Database 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-DB] arrays and email
It would appear that I should check if anyone else has answered a question first! And get some more sleep! Sorry! Ollie -Original Message- From: olinux [mailto:[EMAIL PROTECTED]] Sent: 29 January 2002 20:05 To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] arrays and email The other thing you could do is populate a string of emails and add the BCC header to your mail() function. This way everyone's email will not be seen by all other recipients. Check out the docs at www.php.net for this one a better way to build the string would probably be: while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email_list .= $row[12]; } Then just pass $email_list in the BCC - be careful as some ISP's do not allow mass mailings to be sent in BCC. [i.e. mine is limited to 99 emails and then it gets spam blocked so i must send through the mailing list feature] olinux --- Gurhan Ozen [EMAIL PROTECTED] wrote: Hi kevin, Seems like in your while loop, you are not populating your list array correctly with all the emails you have. Try to have a count value and populate the array list accordingly such as: $count = 0; while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[$count] = $email; $count = $count + 1; } Hope this helps. Gurhan -Original Message- From: Kevin Ruiz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:14 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] arrays and email I'm working on an application that will allow someone to view all attendees for a specific webinar that my company is hosting. I want to allow the user to send one group email to all participants scheduled for that particular webinar. After I connect to my database my code looks like this: ? $sql = select * from webusers where webdate=\$webdate\; $result = mysql_query($sql) or die(couldn't generate a list of the users); while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[] = $email; } echo form method=\post\ action=\doemailattendees.php\\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0 class=\orange4\\n; echo tr\n; echo td valign=\top\pbTo:/b/p/td\n; echo td valign=\top\p\n; foreach ($list as $value) { print $value, ; $to = $value; } echo /p/td\n; echo /tr\n; echo /table\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0\n; echo tr\n; echo td valign=\top\pbSubject:/b/p/td\n; echo td valign=\top\pinput type=\text\ name=\subject\/p/td\n; echo /tr\n; echo tr\n; echo td valign=\top\pbMessage:/b/p/td\n; echo td valign=\top\textarea name=\message\/textarea/td\n; echo /tr\n; echo tr\n; echo td colspan=2 valign=\top\input type=\submit\ value=\submit\/td\n; echo /tr\n; echo /table\n; echo /form\n; ? The $to, $subject, $message variables then get sent to a page that actually mails the message. The problem I'm having is that it's only being sent to the last person in the array. I understand why this is happening but don't know enough about arrays to find a solution. As my code shows I ambitiously tried setting $to to the entire array but that doesn't work. If anyone would be kind enough to help me out I'd greatly appreciate it. Thank you. Kevin www.worktiviti.com -- PHP Database 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 Database 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] __ Do You Yahoo!? Great stuff seeking new owners in Yahoo! Auctions! http://auctions.yahoo.com -- PHP Database 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]