Populating A Select List, what the title says. |
||
Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.
In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.
Zymic Webmaster Forums Web Design & Development Server Side Scripting PHP |
||
![]() |
Populating A Select List, what the title says. |
||
Oct 16 2009, 06:27 PM
Post
#1
|
|
![]() Member ![]() ![]() Group: Members Posts: 90 Joined: 29-May 09 Member No.: 97,073 |
i want to populate a select list with info from my database. however, i need to populate the list with only one of the categories in the table.
@@@/Name/Number @@@/Vegeta/0ver 9000 @@@/Goku/ 100k How would i code it so that the names appear on the select list? CODE foreach($DBInfo as $v) { echo "<option value='$v'>$v</option>"; } echo "</select>"."</br></br>"; that's all i have so far. |
|
|
Oct 16 2009, 08:18 PM
Post
#2
|
|
![]() Outrageously Uber Ninja ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Administrators Posts: 2,831 Joined: 11-March 07 From: UK Member No.: 9 |
Split it by '/':
CODE foreach($DBInfo as $v) { if(!substr_count($v, '/') == 3) continue; list($a,$b,$c) = explode('/', $v); } $b would hold your name (what I presume is the name), you should name the variables to something more contextual though. |
|
|
Oct 16 2009, 09:30 PM
Post
#3
|
|
![]() Member ![]() ![]() Group: Members Posts: 90 Joined: 29-May 09 Member No.: 97,073 |
Split it by '/': CODE foreach($DBInfo as $v) { if(!substr_count($v, '/') == 3) continue; list($a,$b,$c) = explode('/', $v); } $b would hold your name (what I presume is the name), you should name the variables to something more contextual though. that reads like greek to me. explanation for the win? |
|
|
Oct 16 2009, 09:35 PM
Post
#4
|
|
![]() Outrageously Uber Ninja ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Administrators Posts: 2,831 Joined: 11-March 07 From: UK Member No.: 9 |
The manual makes it pretty self explanatory:
CODE if(!substr_count($v, '/') == 3) Ensure there's 3 /'s to ensure list can assign all. http://php.net/substr-count CODE list($a,$b,$c) = explode('/', $v); Assign offset, 0, 1 and 2 to variables $a, $b and $c. http://php.net/list http://php.net/explode |
|
|
Oct 16 2009, 10:32 PM
Post
#5
|
|
![]() Member ![]() ![]() Group: Members Posts: 90 Joined: 29-May 09 Member No.: 97,073 |
i'm not trying to seperate the info in the array.
all im trying to do is list all the entries in the table from one column into a select list. since the number will vary with the size of the table, im not sure how the finite code will work for the infinite condition. example of the tables:
databasepic.jpg ( 8.54k )
Number of downloads: 109the select list i'm trying to populate:
db2.jpg ( 5.1k )
Number of downloads: 107 |
|
|
![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users) |
||
| 0 Members: | ||
Forum Jump |
||
| Lo-Fi Version | Time is now: 20th May 2013 - 06:58 AM |