Solved

db+select list

Posted on 2000-04-12
6
170 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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 and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

813 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now