- I am trying to use this code snippet, to learn how to create a dropdown menu, populated by a mysql database.
- I have worked out the kinks of the database credentials.
- I have created and populated a test database.
- This does actually work, now that it is morning time and the sun is coming up already..
- I do get mostly a blank screen, but with a drop down menu (in the top left corner), with the 2 fields i inserted in my database shown.. So stoked there!
- BUT! I receive the error @ the botoom of this post
- Furthermore... the point of doing this excerise, is to replace the hand made table i use for my ad space, which is popluated by java scripts. So i can move onto table that poplutaes istelf from a database.
- Iam going to post his twice i suppose since its being retarded and wont let me post with my code smippet.. idk maybe i need sleep?
ERROR=
Notice: Undefined variable: partner_block in /var/www/test/test-php-dropdownmenu.php on line 22
naphets
0
Junior Poster in Training
Recommended Answers
Jump to PostYou are appending a string to a variable
$partner_block
that is not defined anywhere else (at least not in the code you posted):$partner_block .= '<OPTION value="'.$partner_id.'">'.$partner_name.'</OPTION>';
Jump to PostIf the variable has not been declared yet, you can not append to it. You can asign to it (with asigning you declare the variable). So just remove the dot (appending operator):
$partner_block = '<OPTION value="'.$partner_id.'">'.$partner_name.'</OPTION>';
That will remove the error in line 22 but I …
Jump to PostOK, so put back the dot you removed and declare the
$partner_block
variable before the while loop (so you can later append to it):$partner_block = ''; while($partner = mysql_fetch_array( $partners )) { $partner_id = $partner['id']; $partner_name = $partner['name']; ## Now, let's assign the partner inside …
Jump to PostSee my post above.
Jump to PostIS there a nice and easy way to re-draw said tables, based on the output,
There is nice and easy way if you do not mind reloading the page. Just send the new values using a form and GET or POST method.
If you do now want to …
All 27 Replies
naphets
0
Junior Poster in Training
broj1
356
Humble servant
Featured Poster
naphets
0
Junior Poster in Training
broj1
356
Humble servant
Featured Poster
naphets
0
Junior Poster in Training
broj1
356
Humble servant
Featured Poster
naphets
0
Junior Poster in Training
broj1
356
Humble servant
Featured Poster
naphets
0
Junior Poster in Training
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
naphets
0
Junior Poster in Training
naphets
0
Junior Poster in Training
naphets
0
Junior Poster in Training
broj1
356
Humble servant
Featured Poster
naphets
0
Junior Poster in Training
naphets
0
Junior Poster in Training
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
naphets
0
Junior Poster in Training
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
naphets
0
Junior Poster in Training
broj1
356
Humble servant
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.