Hi guys hope u r all well and can assist :>)
I have the following snippet of code that exists in a php file.
I have hardcoded all these case entry filenames in this file.
I now have a way to populate a mysql table with these filenames, so now i have 2 copies of them.
1) One in the mysql table, which is always automatically kept up to date
2) In the below php file, which I have to manually update all the time.
Such is the reason why I want to remove the hardcoded filenames in this php file, and just query the mysql table instead to generate the case statements instead.
Here is a snippet of the php file with the hardcoded filenames...
case 'menu2_it_auditing.php':
// menu3:
case 'menu3_it_auditing_compute
rs.php':
case 'menu3_it_auditing_disk.ph
p':
case 'menu3_it_auditing_groups.
php':
case 'menu3_it_auditing_network
ing.php':
case 'menu3_it_auditing_users.p
hp':
case 'menu3_it_auditing_vmware.
php':
// menu4:
case 'menu4_it_auditing_compute
rs_documen
tskb.php':
case 'menu4_it_auditing_compute
rs_documen
tswk.php':
case 'menu4_it_auditing_compute
rs_imagesk
b.php':
case 'menu4_it_auditing_compute
rs_imagesw
k.php':
All of the above filenames exist in my database. So for example,
'menu2_it_auditing.php'
'menu3_it_auditing_compute
rs.php'
'menu4_it_auditing_compute
rs_imagesw
k.php'
all exist as records in a mysql table.
Since I have duplication, BUT I still want to use the functionality of the php file in terms of case statements, I need a way to write a case statement line for every record in the mysql table.
That is...
Replace what i currently have in the php file as follows...
case 'menu2_it_auditing.php':
// menu3:
case 'menu3_it_auditing_compute
rs.php':
etc etc etc
WITH THE BELOW INSTEAD..
case 'menu2_it_auditing.php': <this generated by querying mysql table>
// menu3:
case 'menu3_it_auditing_compute
rs.php': <this generated by querying mysql table>
etc etc...
########################
The following are my mysql details
MySQL database: simeswiki
Table: filename_fil
Columns: id_fil
file_fil
User: root
Password: password
The MySQL statement that returns all the required filenames I need is the following....
select file_fil from filename_fil where file_fil like 'menu%_it%' order by file_fil asc;
Any help greatly appreciated guys as always. :>)
Start Free Trial