Solved

db+select list

Posted on 2000-04-12
6
172 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
  • 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
Industry Leaders: 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

Technology Partners: 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!

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
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…
The viewer will learn how to count occurrences of each item in an array.

679 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