Solved

How do I get $_POST value

Posted on 2015-02-13
3
143 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
3 Comments
 
LVL 1

Accepted Solution

by:
dale_abrams earned 350 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 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 150 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 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