?
Solved

How do I get $_POST value

Posted on 2015-02-13
3
Medium Priority
?
148 Views
Last Modified: 2015-02-15
Working on php code and im population the <select> with data from the database , but when i try to get the selected data nothing is returned and I also need it  in the form of userdata[id] so I can $_POST update the database with the new results

<?php
							$conn = new mysqli($servername, $username, $password, $dbname) or die("Connection Failed");
							$sql = "SELECT * FROM racquet_branch";
							$result = $conn->query($sql);
							?>
							<select name="Select_Brand" class="target" id = "racquet" name="racquet" style="float:right; border:1px solid #CDCDCD;width:302px; position:relative; top:-40px; !important;">
							<?php
							while($row = $result->fetch_assoc()) {
							
							?>
							<option value="<?php echo $row["id"];?>"> <?php echo $row["name"];?></option>
							 
							<?php
							}
							?>
							</select>

Open in new window

0
Comment
Question by:dolamitejenkins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
dale_abrams earned 1050 total points
ID: 40608401
Try this...
<?php
	$conn = new mysqli($servername, $username, $password, $dbname) 
		or die("Connection Failed");
	$sql = "SELECT * FROM racquet_branch";
	$result = $conn->query($sql);
?>
<select name="Select_Brand" class="target" id = "racquet" name="racquet" style="float:right; border:1px solid #CDCDCD;width:302px; position:relative; top:-40px; !important;">
	<?php
		$str = '';			
		while($row = $result->fetch_assoc()) {
			  $str .=  '<option value="' . $row["id"] . '">' . $row["name"] . '</option>';
		}
		echo $str;
	?>
</select>

Open in new window

0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 450 total points
ID: 40609095
This is pretty much PHP-101 and if you want to learn PHP, there are many examples on the internet and in books written over the last 20 years.  This article can help steer you to some good learning resources and more importantly, steer you away from bad learning resources that seem to litter the internet these days.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

If you don't want to learn PHP (and I completely understand that) you might use Meetup or a similar site and look for PHP experts in your area.  A free-lancer can give you a hand with this.  You will have good results in short order and it will not cost you very much money.

If you do want to learn PHP, and you've given yourself some time to exploit the resources in the article above, then you will be able to understand the design pattern in this article which does the kind of "table maintenance" you describe.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12335-PHP-and-MySQLi-Table-Maintenance.html

In any case, be sure to test the answers you get here at E-E.  Not everyone who posts code here has actually tested the code prior to posting it, so be careful that you don't accept any answers that have non-working code samples!
0
 

Author Closing Comment

by:dolamitejenkins
ID: 40611726
thank you
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question