PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
The code below works just fine. Its job is to return the multiple abbreviations which are separated by spaces and stored in a row in my db. They are renamed and then displayed.
My question is, is there a better way to do this than a big elseif statement?
Regards,
Peter
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
You should have a table for the various items and you should have a table to link those items to whatever record this "separated data" is coming from now.
My table for this page includes the following rows:
- id
- name
- description
- city
- state
- country
- type (array mentioned earlier)
So you're saying have the array in "type" refer to a table where the abbreviations are spelled out. I assume the purpose would to centralize the data(best practices)?
I think I get it. So you would have an additional table for say city/st/country/id and join the tables on the query? So I would have "project_loc" in my Projects section that would store the id of the correct location?
psurrena wrote:I think I get it. So you would have an additional table for say city/st/country/id and join the tables on the query? So I would have "project_loc" in my Projects section that would store the id of the correct location?
You're getting it. That would be a much more desirable relational database.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Yeah, basically you want to relate the data in the database and select the data according to its relationship so that by the time PHP gets it, it is already assembled into a usable array set without needing a bunch of resource intensive manipulation.