Solved

db+select list

Posted on 2000-04-12
6
174 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to implement server side field validation and display customized error messages to the client.
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 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 …

687 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