|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Member
Join Date: Jun 2004
Location: UK
Posts: 17
|
Swapping strings and displaying in loops problems
Does anybody know how I could improve this script?
PHP Code:
I know I've not been too economical with this one...please don't laugh too loudly at this feeble attempt. All the best, James |
|
|
|
|
|
#2 |
|
SitePoint Addict
![]() ![]() ![]() Join Date: Aug 2004
Location: michigan
Posts: 246
|
You could use a switch(), case() instead of 43 if()'s, and as long as you used "break;"s after each one, it could help your script run faster in some cases. Otherwise, that's really not too much to put inside of a while loop.
Also, if you want runner to be a list, you'll want to use if ($varname =="f2") $runner .= "Toilet block"; (notice the ".=") otherwise, unless I'm missing something, $runner will end up being "Tea & Coffee En-suite" every time. What is the query returning? And where in the script do you utilize the results? I was expecting to see "$row['field_name']" in there somewhere. Does this script work for you? If it does, use it. My only suggestion would be the first sentence I wrote. And I'm obviously missing something. |
|
|
|
|
|
#3 | ||
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: 3rd rock from the sun
Posts: 1,005
|
Quote:
Unless you have more than one country with the same ID? - unlikely, so make sure its a unique field in your database.... So why are you doing a "while"? Thats for looping thru a set, array of results. Your query is only getting one result or, no result. so use plain: $row=mysql_f....... Now, to make sure it brings back a result which is non zero.... Quote:
|
||
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 23:16.









Linear Mode
