Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I get $_POST value

Posted on 2015-02-13
3
Medium Priority
?
149 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
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 …

636 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