Solved

db+select list

Posted on 2000-04-12
6
173 Views
Last Modified: 2006-11-17
hi...
im retriving data from database:
...
while ($row=mysql_fetch_object($result)){
<tr><td>
<select name="priority">
<option value="1">Top</option>
<option value="2">Middle</option>
<option value="3">Bottom</option>
</select>
}


<td><?echo $row->name;?></td></tr>

that's gives me a list with names and a select list for each name.
in the next page i want to retrive the data like that:
item 1 : select list result : 1
item 2 : select list result : 3
item 3 : select list result : 2
item 4 : select list result : 1
...
this is a problem since the select name="priority" is common to all records.
how can i do this?

elad
0
Comment
Question by:eladr
[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
  • 4
  • 2
6 Comments
 
LVL 2

Expert Comment

by:maxkir
ID: 2707739
Try using
<select name="priority[<?php echo $row->name;?>]">
to distinguish between rows ...

so on the result page you'll have associative array $priority
with keys - names.

Or, if there is id for each name, use this:
<select name="priority[<?php echo $row->id;?>]">
0
 
LVL 1

Author Comment

by:eladr
ID: 2707755
o.k.
i did that.
how can i indicates in the next page
which id selected what.
sorry...i know how to do it in asp but
im beginner with php.

elad

i can raise points if needed.
0
 
LVL 2

Accepted Solution

by:
maxkir earned 25 total points
ID: 2707770

Assuming that you've chosed the last variant of select:

while ( list($id, $val) = each( $priority) )
{
     print "Name_ID: $id<BR>\n";
     print "VALUE: $val<BR>\n";
}

It is your position to raise points or not ;-)

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:eladr
ID: 2707897
Adjusted points from 20 to 25
0
 
LVL 1

Author Comment

by:eladr
ID: 2707898
i am trying to combine all this to " insert into "  database.
the database is not update how ever i dont have any errors.
BTW - im getting the name_id and the $val o.k.

while ( list($id, $val) = each( $priority) )
                    {       
$sql="insert into reported_mutation priority values($val) where id='$id'";
                                    $result=mysql_db_query("appscan",$sql);
                        #that's works good: print "Name_ID: $id<BR>\n";
                        #that's works good: print "VALUE: $val<BR>\n";
                    }
0
 
LVL 1

Author Comment

by:eladr
ID: 2707939
ignore my last comment.
it's works - you will gwet the points soon.
elad
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

737 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