Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 19th, 2004, 07:15 AM
Authorized User
 
Join Date: Jul 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default select id from row in array

How do you select the id row number when in a loop like in the code below?:
 
Quote:
quote:echo "<SELECT NAME=\"f_prod_id\">";
Quote:
while ($row=mysql_fetch_array($mysql_result))
{
  $manufacturers_id=$row["manufacturers_id"];
  $manufacturers_name=$row["manufacturers_name"];
  echo "<OPTION>$manufacturers_name</OPTION>";
}
echo "</SELECT><br>";
This code above places the text value of $manufacturers_name into f_prod_id. What i would like it to do it actually place the manufacturers_id into f_prod_id so i can back reference it when i come to extract this data from another table.

Any ideas?


Michael.
__________________
Michael.
 
Old July 19th, 2004, 09:03 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

echo "<select name=\"f_prod_id\" id=\"f_prod_id\">";
while ($row=mysql_fetch_array($mysql_result))
{
  $manufacturers_id=$row["manufacturers_id"];
  $manufacturers_name=$row["manufacturers_name"];
  echo "<option value=\"$manufacturers_id\">$manufacturers_name</OPTION>";
}
echo "</select><br />";

On POSTing this, you'd have the value of $manufacturers_id for the option selected in the variable $_POST['f_prod_id']. In fact, I think only Nozilla/Netscape can cope with implicitly inserting the text of a select in place of the value if no value is given. IE woud definitely choke on it.

Take it easy,
Dan
 
Old July 19th, 2004, 11:00 AM
Authorized User
 
Join Date: Jul 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Simple as that! Excellent.

Thanks D.

Michael.





Similar Threads
Thread Thread Starter Forum Replies Last Post
html table row id myself.panku ASP.NET 1.x and 2.0 Application Design 0 April 17th, 2008 01:56 PM
Select row in GridView WITHOUT using Select button rao965 ASP.NET 2.0 Professional 1 February 15th, 2008 10:44 AM
show columns with same ID in the same row yuvalk SQL Server 2005 4 February 2nd, 2007 07:46 PM
select Max 2 rows for each ID veeruu SQL Language 1 January 31st, 2006 05:08 AM
Creating a Unique ID for each row maxworlund SQL Server DTS 1 March 8th, 2005 09:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.