RE: [PHP-DB] Pull Down Menu with ODBC query
BTW I want to make sure I am doing this correctly... with that current script (edited below with your fix) will I be able to pass that selection on into a further PHP page? I do not see how without assigning a variable to it and passing it with POST... how would I go about this? -- Original message -- From: Simcha [EMAIL PROTECTED] odbc_fetch_array() returns an associative array, so will you need to use $row[' sls_his_cust_id'] instead of $row[0]. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2008 10:14 PM To: php-db@lists.php.net Subject: [PHP-DB] Pull Down Menu with ODBC query I am having trouble getting this script to populate the query data into a pull down menu. The SQL script works fine and displays the data with odbc_result_all but will not put it in the menu. Script is as follows: ?php $conn = odbc_connect(HOMES, , ); $billdate = $_POST[ 'billdate' ]; $query = (SELECT DISTINCT sls_his_cust_id FROM sls_his where sls_his_prchdat_alt = $billdate); $result = odbc_exec($conn, $query); echo FORM method=POST action=getcustdata.php; echo SELECT name=column_name; while($row = @odbc_fetch_array($result)) { echo OPTION VALUE=\$row[sls_his_cust_id]\$row[sls_his_cust_id]/OPTION; } echo /SELECTINPUT TYPE=submit name=submit VALUE=\Get Results\/FORM; ? Any ideas? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.6.0/1604 - Release Date: 11/08/2008 05:50 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pull Down Menu with ODBC query
Try something like this: tddiv align=right SELECT name=menu ?php $conn = odbc_connect(HOMES, , ); $billdate = $_POST[ 'billdate' ]; $q_menu = SELECT DISTINCT sls_his_cust_id FROM sls_his where sls_his_prchdat_alt = $billdate; $r_menu = odbc_exec($conn, $q_menu); while ($rec_menu = @odbc_fetch_array($r_menu)) $menu[] = $rec_menu; echo OPTION value=\\--SELECT--/OPTION\n; foreach ($menu as $m) { if ($m['sls_his_cust_id'] == $_POST['menu']) echo OPTION value=\{$m['sls_his_cust_id']}\ SELECTED{$m['sls_his_cust_id']}/OPTION\n; else echo OPTION value=\{$m['sls_his_cust_id']}\{$m['sls_his_cust_id']}/OPTION\n; } ? /SELECT /td
Re: [PHP-DB] Pull Down Menu with ODBC query
Thanks everyone for your help so far. The last two responses I got were great and worked. However I stuck with my original script with the small $row fix presented earlier and it works great. The only problem I see with the last two are that there is no scripting to push to the next page like I have set. Saying that here is what I currently have: ?php $conn = odbc_connect(HOMES, , ); $billdate = $_POST[ 'billdate' ]; $query = (SELECT DISTINCT sls_his_cust_id FROM sls_his where sls_his_prchdat_alt = $billdate); $result = odbc_exec($conn, $query); echo form method=post action=getcustdata.php; echo SELECT name=sls_his_cust_id; while($row = @odbc_fetch_array($result)) { echo OPTION VALUE=\$row[sls_his_cust_id]\$row[sls_his_cust_id]/OPTION; } echo /SELECTINPUT TYPE=submit name=sls_his_cust_id VALUE=\Get Data\/FORM; ? I need to know how to name the selection so I can push it to the next page using the submit button. The next page so far is as follows: ?php $conn = odbc_connect(HOMES, , ); $sls_his_cust_id = $_POST[ 'sls_his_cust_id' ]; $query = (SELECT sls_his_d2_nam, cust_phone_no, cust_phone_no_2, cust_phone_no_3, sls_his_invc_no, sls_his_so_bdat, sls_his_d2_adrs_1, sls_his_d2_adrs_2, sls_his_d2_city, sls_his_d2_state, sls_his_d2_zip_cod, slm_nam, sls_his_pft_ctr, sls_his_prchdat_alt FROM sls_his , cust , slm where CUST_ID = SLS_HIS_CUST_ID AND slm = sls_his_slm_1 and sls_his_cust_id = $sls_his_cust_id); $result = odbc_exec($conn, $query); odbc_result_all($result) ? I need to be able to pass the selected CUSTID on to this page so I can display all the data pertinent to that customer... also I would like to be able to use the billdate that was present earlier but am not sure how to push it through again... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php