Solved

How do I get $_POST value

Posted on 2015-02-13
3
140 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 108

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now