CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 SHOW TABLE STATUS - ListBox

Print topic Send  topic

Author Message
Robert Little
Posted: 01/31/2004, 12:10 PM

:-<Hello people,

I have the following problem:

to fill a ListBox I use the following command of MYSQL:
"SHOW TABLE STATUS FROM database1 LIKE 'table_name_root% '"

The ListBox is filled in a correct way, with the names of the existing tables in the database.

Now, I need to sort the content of the ListBox in alphabetical order: Preferably with the function php sort () or array_multisort ().


Can somebody tell me if this is possible?


Thank you,

Robert Little
peterr


Posts: 5971
Posted: 01/31/2004, 4:52 PM

I'm not sure if I understand your question correctly, but possibly you could try this:
Open the ListBox Data Source property (click on [...] button) and at the bottom of the Data Source dialog you should see the "Order by" section. Click on the [...] button there and specify your sort order.

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Robert Little
Posted: 02/01/2004, 12:56 PM

:-/ Hello Peter,
thank you per your answer. The problem with the sentence ( "SHOW TABLE STATUS FROM database1 LIKE 'table_name_root% '" )
is that when not existing a "SELECT" it doesn't accept "ORDER BY."

I was attempting a sort in the section of events (Before Show - Custom Code) but I have not still been able to transfer an array toward the ListBox control.

Sincerely

Robert
Apologize my English, it is very bad.
peterr


Posts: 5971
Posted: 02/01/2004, 2:28 PM

OK. I see the problem now. Since "SHOW TABLE STATUS" doesn't support ORDER BY, possibly try any of these approaches:
1. Create a Temporary table in Before Show event of the form (or maybe even in After Initialize of the page ) and populate the temporary table programmatically, using code similar to the shown at the bottom of: http://www.mysql.com/doc/en/SHOW.html

2. Or specify that your listbox Data Source Type is "ListOfValues" and then programmatically populate it. See an example here:
http://docs.codecharge.com/studio/html/ProgrammingTechn...stOfValues.html

3. Or create a Label instead of ListBox and programmatically create an HTML ListBox that will replace your Label.

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Arnor Baldvinsson
Posted: 02/01/2004, 5:19 PM

Hi Robert,

<RobertLittle@forum.codecharge (Robert Little)> wrote in message
news:5401d67ed51f32@news.codecharge.com...
> :-/ Hello Peter,
> thank you per your answer. The problem with the sentence ( "SHOW TABLE
STATUS FROM database1 LIKE 'table_name_root% '" )
> is that when not existing a "SELECT" it doesn't accept "ORDER BY."
>
> I was attempting a sort in the section of events (Before Show - Custom
Code) but I have not still been able to transfer an array toward the
ListBox control.

I haven't done this in MySQL, but in for example Sybase Anywhere and I think
MS-SQL you can do queries to thesystable table, like Select * from SYSTABLE
will list all tables in the database. It appears that MySQL does not have
that option (at least not the engine I have here at home) so maybe you could
create a temp table in the db and put the output from SHOW TABLE... into the
temp table, and then use that in CCS?

Best regards,

--

Arnor Baldvinsson
Icetips Software
San Antonio, Texas

DonB
Posted: 02/02/2004, 8:03 AM

Have you looked at the List Of Values datasource option? You can
programmatically define a list of values (by extracting from the lookup
table) and sort it however you like. Not the fastest way to create the
list, but if it's short (and presumably a list of database tables would be a
short list), doing an array-sort in your script would work. As to the
details on how you'd implement it, you can create a static LOV in the
property window (for the listbox) and use that as your guide. The short
answer would be: put code in the Listbox Before Show event to execute a
query against your database connection, then loop through the result set to
create an array, sort the array, then add the array elements to the Listbox
via its AddValue property

--
DonB

http://www.gotodon.com/ccbth


"Arnor Baldvinsson" <arnor_ccs@icetips.com> wrote in message
news:bvk8j1$p2j$1@news.codecharge.com...
> Hi Robert,
>
> <RobertLittle@forum.codecharge (Robert Little)> wrote in message
>news:5401d67ed51f32@news.codecharge.com...
> > :-/ Hello Peter,
> > thank you per your answer. The problem with the sentence ( "SHOW TABLE
> STATUS FROM database1 LIKE 'table_name_root% '" )
> > is that when not existing a "SELECT" it doesn't accept "ORDER BY."
> >
> > I was attempting a sort in the section of events (Before Show - Custom
> Code) but I have not still been able to transfer an array toward the
> ListBox control.
>
> I haven't done this in MySQL, but in for example Sybase Anywhere and I
think
> MS-SQL you can do queries to thesystable table, like Select * from
SYSTABLE
> will list all tables in the database. It appears that MySQL does not have
> that option (at least not the engine I have here at home) so maybe you
could
> create a temp table in the db and put the output from SHOW TABLE... into
the
> temp table, and then use that in CCS?
>
> Best regards,
>
> --
>
> Arnor Baldvinsson
> Icetips Software
> San Antonio, Texas
>
>

Robert Little
Posted: 02/02/2004, 7:58 PM

:-) Hello everyone!.

Thanks for its advice!. Finally it could be resolved the problem through the following code, in the Listbox Before Show event (partial):

// Realizar una consulta SQL (MySQL Query)
$consulta = "SHOW TABLE STATUS FROM lbve_intranet LIKE 'iat_componente_detalle%'";
$resultado = mysql_query($consulta) or die("La consulta falló: ".mysql_error());
//
//Obtener los valores y pasarlos hacia una matríz (push to array)
while($rows = mysql_fetch_assoc($resultado)) {
//original position ("Name", "Comment")
// $datosListBox[] = array($rows["Name"], $rows["Comment"]); // it doesn't work
//
// "Name" and "Comment" in different position
$datosListBox[] = array($rows["Comment"], $rows["Name"]);
}
//
// sort array
asort($datosListBox);
//
// se intercambian valores (swaping to original position)
while(list($clave, $valor)=each($datosListBox)){
// se crea nuevo array con valores intercambiados (new array with variables swapped)
$arraySwap[] = array($valor[1],$valor[0]);
}
//
// se transfiere array hacia ListBox (transfer array to the ListBox)
$iat_nombre_tabla_de_compo->iat_nombre_de_tabla->Values = $arraySwap; // this works fine!
//
// -------------------------
//End Custom Code

Thank you for your patience.

Best regards,


Robert Little.

Add new topic Subscribe to topic   


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.