|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Article Discussion: Using Control Structures in PHP
Using Control Structures in PHP If you have any questions or comments about this article please post them here.
You can read the article here . |
|
#2
|
|||
|
|||
|
Where's switch? Should be mentioned along with if/else & if/elseif/else
|
|
#3
|
|||
|
|||
|
I was thinking that aswell when I was putting this article up. Perhaps the writer is wishing to place the switch in another article. But I must agree with you.
The switch statement is an important Control Structure. For those wondering what this structure is, here is the low down. PHP Code:
The switch is great for multiple conditions. Saves writing multiple if/else if statements. |
|
#4
|
|||
|
|||
|
Dynamic Pulldown from multiple columns
I think this is useful; more useful would be to know how to write PHP to pull both A) the option value and B) option from two different columns in the same MySQL table. I'm trying to set up a pulldown of country names from the column 'country_name' that will select a value from the 'country_id' column in the same table, because other related tables are keyed to 'country_id', not 'country_name.' Would it be easier just to run a second query to select the country_id from the table where country_name = $universe ?
the code that pulls the _same_ info for value and value option: ... require_once ('../mysql_connect.php'); // Connect to the db. echo '<b>Universe:</b>'; $sql = "SELECT DISTINCT(country_name) FROM country"; $resultd = @mysql_query($sql); echo "<SELECT NAME=universe>"; while($row = @mysql_fetch_array($resultd)) { echo "<OPTION VALUE=\"$row[0]\">$row[0]</OPTION>"; } |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > Article Discussion: Using Control Structures in PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|