mysql
John Dixon asked:


Quite often when you are developing web sites or applications it is necessary to create a drop down list box that contains entries from a database table. You can, of course, hard code the items in the drop down list box, but this isn’t really very elegant, and can create problems if the entries in the database table change at a later date. It is much better to extract the entries from the database table directly and then populate the drop down list box using those entries.

Creating the database table

The following script, database-table.sql, could typically be used to create a database table (called ‘years’) that contains, for example, a list of years. These will be the entries that appear in the drop down list box.

database-table.sql

create table years

(  yearID integer auto_increment,

   year varchar(30),

   primary key (yearID)

);

insert into years (yearID, year) values (’1′, ‘2007-2008′);

insert into years (yearID, year) values (’2′, ‘2008-2009′);

insert into years (yearID, year) values (’3′, ‘2009-2010′);

insert into years (yearID, year) values (’4′, ‘2010-2011′);

insert into years (yearID, year) values (’5′, ‘2011-2012′);

insert into years (yearID, year) values (’6′, ‘2012-2013′);

The following PHP script (populate-list.php), which would form part of a form, will extract all the entries from the ‘years’ database table, and use them to populate the drop down list box.

populate-list.php



If the entries in the database table change at some stage in the future, those changes will be automatically reflected in the drop down list box in the form.

cpanel
James Smith asked:


I have uploaded a rar file but I understood that my cpanel can’t extract the file content. How to extract it’s contents? Is it possible to use a php script?
I need a script to give me this ability. Also, my files are about 100 MB, will script work?
mysql
Batman asked:


I have a mysql server up and running on my local machine, but I can’t seem to get a simple php script to execute on it. I thought I had php installed correctly. Is there some special folder I have to save the script in to make it work. I have it in my bin folder right now. Is there an easy way to know whether I have php installed correctly or not?