Solved

How do I get $_POST value

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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

19 Experts available now in Live!

Get 1:1 Help Now