Solved

db+select list

Posted on 2000-04-12
6
168 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
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…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

760 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

21 Experts available now in Live!

Get 1:1 Help Now