CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Listbox Custom Inital value Problems with PHP4 ?

Print topic Send  topic

Author Message
TheNetGuy
Posted: 08/04/2003, 4:28 AM

Testbox includes:

OS: Win 98 (yah yah, old I know)
SERVER= MSSQL personal edition win98
Test web Srv= PWS 4
PHP version= 4.3.2 CGI (session = yes, reg global=on)
Web Browser = IE 5.5 + netscape 4.79 Same Problem on both

PROBLEM
--------
1. Created a Custom Initial Value listbox for a search form the system.
2. generate page
3. When viewing page the listboxes default to the 1st record on the Dbase (not the 'all' option that i specified under the "Display value" for the Custom Initial Value checkbox.

NOTES: When expanding the list box the 'ALL' option is there, and all works as expected. The ALL even works as expected.

But it is a problem that:
1. initially the listbox displays the 1st value in the 1st row of data in the DB
2. even after selecting ALL for all the options, then hitting Search will reset the search listbox back to the 1st values in the 1st row of data.
3. If setting one of the list boxes to value 'a' , and changing all others to ALL, after hitting SEARCH the list box that was changed to 'a' stays 'a' and the other list boxes revert back to the 1st value again.

My guess is it is a PHP setting somewhere.

Any thoughts?




TheNetGuy
Posted: 08/13/2003, 4:01 AM

Ok update.



The listboxes do not default to the custom values with Any Db, and on IIS /xp pro as well. PHP 4.3.2



1. Creating 'Custom Initial Value' and setting the list box to use 'list of values' THEN it DOES DEFAULT TO the 'Custom Initial Value listbox ' (set to 'All' with default and submit values blank)

2. When mapping the listbox to a table/primarykey/showing then when viewing the page the LIST box Defaults to the 1st record and NOT the 'Custom Initial Value listbox ' (set to 'All' with default and submit values blank)

3. Using ASP it works fine, PHP is 'NO GO'


I am curious why noone has replied, perhaps it is because this is a silly question? Is it in a FAQ somewhere? Common knowledge?


Please someone reply. Even if it is to tell me im an idiot.

TheNetGuy
Posted: 08/13/2003, 4:15 AM

Ok sorry for ramble, I found out

1. CUSTOM INITAL VALUES do not work with 'list of valus' as described above

2. I cannot get CUSTOM INITAL VALUES to work at all with PHP 4.3.2
TheNetGuy
Posted: 08/14/2003, 10:57 PM

Ok spent some time and figured it out.
HOPEFULLY THE MAKERS CAN IMPLEMENT A CODE CHANGE TO FIX THIS ISSUE

I worked with a PHP guru and tracked the issue down to the IDENTITY seed creation of the database. (or any database with autoincrementing number colum)

If the autoincrementing number STARTS at 0, this will cause problems with the INITAL DISPLAY VALUE for listboxes w/PHP coding:

PHP considers the value "" the same as "0"

Because the Database has a '0' as the first record it retrieves the :
'if($key == $fldCUST_ORDER_id)'
always is TRUE (with a new page reload, or no PARAMS) Thus tagging the first record in the table as the SELETED value (the default value)

Their are 3 solutions that one can do:

1. Do not Start the database autoincrementing number at "0"
2. manually edit all the code from:
'if($key == $fldCUST_ORDER_id)'
TO
'if($key == $fldCUST_ORDER_id && $fldCUST_ORDER_id != "")'
^^^^^^ADDED CODE HERE^^^^^
(changing to the proper table variable name of course)
3. Hoping the Creators of CODECHARGE will put this in patch.



SEE Reference 'a' below in code
also is their any problems with changing the below:

$tpl->set_var("Selected", "");
TO
$tpl->set_var("Selected", "SELECTED");

This would help compatibility in older browsers ?

Thks for reading and I hope that i didnot confuse you too much
I hope to get an aknowledgement that a fix will be in place ASAP.





The problem happens in the followin CODE generated VIA CodeCharge:
================================================================
// Set variables with search parameters
//-------------------------------

$fldCUST_ORDER_id = strip(get_param("CUST_ORDER_id"));

//-------------------------------
// Search Show begin
//-------------------------------
//-------------------------------
// Search Show Event begin
// Search Show Event end
//-------------------------------
$tpl->set_var("SearchLBCUST_ORDER_id", "");
$tpl->set_var("ID", "");
$tpl->set_var("Value", $sCUST_ORDER_idDisplayValue);
$tpl->set_var("Selected", "");
^^^^^^^^^^^^^^ REFERENCE 'a' ^^^^^ SEE ABOVE^^^^

$tpl->parse("SearchLBCUST_ORDER_id", true);
$lookup_CUST_ORDER_id = db_fill_array("select ORDERS_id, ORDERS_name from CLIORDERS order by 2");

if(is_array($lookup_CUST_ORDER_id))
{
reset($lookup_CUST_ORDER_id);
while(list($key, $value) = each($lookup_CUST_ORDER_id))
{
$tpl->set_var("ID", $key);
$tpl->set_var("Value", $value);

if($key == $fldCUST_ORDER_id)
^^^^^^^^^^^^^^^^^^^^^^^^ PROBLEM HERE ^^^^^^^^^^^^^^^
----------------------------------------------------------
CHANGE TO :
if($key == $fldCUST_ORDER_id && $fldCUST_ORDER_id != "")
----------------------------------------------------------

$tpl->set_var("Selected", "SELECTED" );
else
$tpl->set_var("Selected", "");
$tpl->parse("SearchLBCUST_ORDER_id", true);
}
}


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.