CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Listbox in my caption row

Print topic Send  topic

Author Message
mtsoulis

Posts: 12
Posted: 09/29/2015, 10:29 AM

I have the editable form: stusers
I have a list box in the caption row of my editable form: classes
I have the textbox in my editable form: class
My case (explanation):
So, I use the editable form "stusers" to change the class of my students because is the beggining of the new school year.
I search the students of the class A
In my editable form "stusers" Ι see 24 records, the elements of my 24 students.
From the previous year, the textbox "class" write Class A
The listbox "classes" in the caption row contains all the classes of my school.
I would like selecting from the listbox "classes" the item Class B to change at once the content of the textbox "class" from Class A to Class B automatically for all my 24 records.
I will appreciate any help
Best regards from Greece
_________________
Miltos-Greece
View profile  Send private message
pbarkley

Posts: 37
Posted: 10/01/2015, 1:29 PM

Hi Miltos.

Two things. First, if you only have 24 students to change from one class to another, it would be much faster to just change them in your editable grid. Use a listbox in each row that has the classes, and then you can change 10 at a time, or however many are in your editable grid, by just selecting a different class for each student (i.e., each row) and submitting the form. Really, you can change all 24 in about 60 seconds! And perhaps you might need to do that once a year, so it's not worth putting a lot of time in programming in my opinion. :-)

However, I know that's not what you want to do. You want the system to do this by your selecting a class from a list box and then clicking a button to change all of them at once. I have many screens that work this way, although they typically change hundreds if not thousands of records at one time. IF your situation is that you want to change ALL the students in Class X to Class Y at one time, then you should start with a new page and form, or at least a new form on this page. You can start with CCS creating a record, say, and then remove everything you don't want, i.e., just leave a couple rows for your list boxes and the Submit button--or simply create an html form, whichever is easier. You need one list box for the class you're changing FROM, and another list box for the class you're changing TO. Go into the code for the Submit button, and do several things.

First, check to make sure the user chose something in both list boxes, or else quit. If you don't want to code a dialog box to tell the user that, then tell them in html on the screen that nothing will happen if they don't have both selected. Check for anything else you want, like someone trying to change everyone to a lower class instead of a higher class, whatever your rules are for what is not allowable.

When you're satisfied that both boxes are chosen OK, then add a single line of SQL to execute an UPDATE, such as SET ClassID = 57 WHERE ClassID = 23. You'll get the ClassID numbers from your class table, assuming you have a primary key of ClassID and a ClassName of "A" or whatever. So the user chooses the first listbox and then the second, and you use the contents of those to build the SQL so the SET and WHERE come out using those variables.

A little tip. Since you'll be writing something like the following, always test it by doing an echo and die before ever running the SQL. I print it to the screen, debug it by eye, and if it looks OK I copy and paste it to phpMyAdmin and run it to see if it actually runs, especially on more complicated SQL. It's easy to screw up and get a period inside the quotes or otherwise mangle the line. Your SQL will look something like this:

$db = new clsDBConnection1();  
$SQL = "UPDATE Class SET ClassID = ".$classform->s_ClassID2->GetValue()." WHERE ClassID = ".$classform->s_ClassID1->GetValue();  
$db->query($SQL);  
$db->close();  

I think in your case that you just needed the concept of how to do this, and if I understood your need correctly, this should work. Of course you need to be able to write the specific lines with the correct syntax, but this should get you started.

Good luck!
Paul
View profile  Send private message

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.