Hi there. A bit of a PHP novice, but getting there.
This project I'm working on uses a MySQL DB that contains travel advice to around 200 countries with the following structure:
ID
Country_Name
Date_Updated
Diphtheria
Mening
Yellow
Polio
Typhoid
Malaria
HepatitisA
HepatitisB
Rabies
Tuberculosis
Cholera
Tickborne
Japanese
Text
The above bolded fields contain single line reccommendations for each specific disease, but for a lot of countries, one or more of these fields are blank as there is no risk.
What I'm trying to do maybe not worth the time, but here goes.
I want to start by filling an array with the fields from the database.
Then I want to run through a for statement for the length of the array, and display only the records which aren't empty.
To give you an idea, I can acheive this using multiple if statements as in the following:
[blue]if($resultrow["Diphtheria"]) {
$Text = $Text . "<b>Diphtheria: </b>" . $resultrow["Diphtheria"] . "<br><br>";
}
if($resultrow["Mening"]) {
$Text = $Text . "<b>Meningitus: </b>" . $resultrow["Mening"] . "<br><br>";
}[/blue]
Obviously where the "<b>Diphtheria: </b>" part is I want to replace with a peice of code that displays the field name that it is displaying.
Can anyone point me in the direction of a decent tutorial on filling arrays with database elements and using them in this way. I've found a bit of info on arrays but can't find anything on getting database fields without specifically writing each field into an array.
Thanks
This project I'm working on uses a MySQL DB that contains travel advice to around 200 countries with the following structure:
ID
Country_Name
Date_Updated
Diphtheria
Mening
Yellow
Polio
Typhoid
Malaria
HepatitisA
HepatitisB
Rabies
Tuberculosis
Cholera
Tickborne
Japanese
Text
The above bolded fields contain single line reccommendations for each specific disease, but for a lot of countries, one or more of these fields are blank as there is no risk.
What I'm trying to do maybe not worth the time, but here goes.
I want to start by filling an array with the fields from the database.
Then I want to run through a for statement for the length of the array, and display only the records which aren't empty.
To give you an idea, I can acheive this using multiple if statements as in the following:
[blue]if($resultrow["Diphtheria"]) {
$Text = $Text . "<b>Diphtheria: </b>" . $resultrow["Diphtheria"] . "<br><br>";
}
if($resultrow["Mening"]) {
$Text = $Text . "<b>Meningitus: </b>" . $resultrow["Mening"] . "<br><br>";
}[/blue]
Obviously where the "<b>Diphtheria: </b>" part is I want to replace with a peice of code that displays the field name that it is displaying.
Can anyone point me in the direction of a decent tutorial on filling arrays with database elements and using them in this way. I've found a bit of info on arrays but can't find anything on getting database fields without specifically writing each field into an array.
Thanks