i have this form that edits current documents which are stored in a mysql db. these documents can have single or multiple document owners, which are just users specifically picked.
now, i want to dump the whole list of users into the drop-down box, and when i get to the names which were selected in the past, they would be highlighted. my problem is that the names keep on repeating themselves the same number of times there are selected names.
here's my code: -
-
<?
-
$doc_owners = get_result("SELECT doc_owners.auth_uname FROM doc_owners WHERE ctrl_no = '{$ctrl_no}' ");
-
-
while($row = mysql_fetch_row($doc_owners))
-
$curr_owners[] = $row[0];
-
-
$res = get_result("SELECT users.username,users.full_name FROM users,org_roles WHERE users.org_role_id = org_roles.org_role_id ORDER BY org_roles.org_role_id");
-
while($names = mysql_fetch_row($res))
-
{
-
foreach($curr_owners as $i)
-
{
-
if ($names[0] != $i)
-
echo"<option value=".$names[0]." >".$names[1]."</option>";
-
else{
-
echo"<option value=".$names[0]." selected='selected'>".$names[1]."</option>";
-
unset($i);
-
}
-
}
-
}
-
echo"</select>";
-
-
thanks! you guys never failed to help me..^^,
cheers!
4 1195
i have this form that edits current documents which are stored in a mysql db. these documents can have single or multiple document owners, which are just users specifically picked.
now, i want to dump the whole list of users into the drop-down box, and when i get to the names which were selected in the past, they would be highlighted. my problem is that the names keep on repeating themselves the same number of times there are selected names.
here's my code: -
-
-
-
<?
-
$doc_owners = get_result("SELECT doc_owners.auth_uname FROM doc_owners WHERE ctrl_no = '{$ctrl_no}' ");
-
-
while($row = mysql_fetch_row($doc_owners))
-
$curr_owners[] = $row[0];
-
-
$res = get_result("SELECT users.username,users.full_name FROM users,org_roles WHERE users.org_role_id = org_roles.org_role_id ORDER BY org_roles.org_role_id");
-
while($names = mysql_fetch_row($res))
-
{
-
foreach($curr_owners as $i)
-
{
-
if ($names[0] != $i)
-
echo"<option value=".$names[0]." >".$names[1]."</option>";
-
else{
-
echo"<option value=".$names[0]." selected='selected'>".$names[1]."</option>";
-
unset($i);
-
}
-
}
-
}
-
echo"</select>";
-
-
thanks! you guys never failed to help me..^^,
cheers!
Please put this code just before your second while loop and post your output, i want to see what the data looks like.
[php]
print_r($curr_owners);
print_r($names);
die("END");
[/PHP]
Please put this code just before your second while loop and post your output, i want to see what the data looks like.
[php]
print_r($curr_owners);
print_r($names);
die("END");
[/PHP]
nevermind, i solved this one already.. ^_^ thanks anyway...
nevermind, i solved this one already.. ^_^ thanks anyway...
How did you solve said problem?
How did you solve said problem?
what i did wrong was i queried twice and tried to compare 2 arrays of names, which means that there was a tendency to have duplicate entries. that was the hard way. but there was an easier way.
what i did was i queried the general list of names, then for each name in the general list, i would query the project document owners. if there was an entry with the same project id with their name, then i would add the 'select' option, else dont.
here's the code. -
<select name="doc_owners[]" multiple="multiple">
-
-
<?
-
$res = get_result("SELECT users.username, users.full_name
-
FROM users,org_roles
-
WHERE users.org_role_id = org_roles.org_role_id
-
ORDER BY full_name");
-
while($names = mysql_fetch_row($res))
-
{
-
$doc_owners = get_result("SELECT doc_owners.*
-
FROM doc_owners
-
WHERE ctrl_no = '{$ctrl_no}' && auth_uname = '{$names[0]}'");
-
-
$num = mysql_num_rows($doc_owners);
-
if ($num)
-
echo"<option value=".$names[0]."
-
selected='selected'>".$names[1]."</option>";
-
else
-
echo"<option value=".$names[0]." >".$names[1]."</option>";
-
}
-
echo"</select>";
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Christopher Jeris |
last post by:
I am relatively new to JavaScript, though not to programming, and
I'm having trouble finding the idiomatic JS solution to the following
problem.
I have a table with (say) fields f1, f2, f3. I...
|
by: Federico G. Babelis |
last post by:
Hi All:
I have this line of code, but the syntax check in VB.NET 2003 and also in
VB.NET 2005 Beta 2 shows as unknown:
Dim local4 As Byte
Fixed(local4 = AddressOf dest(offset))
...
|
by: alanbe |
last post by:
Greetings
I am making a flashcard type application to help me in my TCP/IP
protocols test.
My instructor will test us periodically on how a device or networking
function relates to the OSI...
|
by: scandal |
last post by:
I am a javascript newbie working on a script that checks whether a
"path" from one element in an array to another is "blocked." Currently,
the script pushes an already processed cell index (hence...
|
by: SilverWolf |
last post by:
I need some help with sorting and shuffling array of strings. I can't
seem to get qsort working, and I don't even know how to start to shuffle
the array. Here is what I have for now:
#include...
|
by: bsder |
last post by:
Hi,
Can anyone please tell me how to calculate the size of the following
4-dimensional array, and now to use qsort for sorting on this array?
double sp = { 4.0, 5.0, 6.0 };
double spa = {
{...
|
by: Dan |
last post by:
I wonder if anyone has suggestions for reducing the amount of time it would take to search my array using the function that I have written. I want to find a position in the array of an item that...
|
by: Leszek |
last post by:
Hi.
Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
What i want to do is sending an array to a script, and this script should
add all values from...
|
by: eastern_strider |
last post by:
I'm running into problems about defining a comparison function for a
map which has a user defined key. For example:
class Key {
public:
string name;
int number;
Key (na, nu) : name (na),...
|
by: rkk |
last post by:
Hi,
I have written a generic mergesort program which is as below:
---------------------------------------------------------
mergesort.h
-----------------------
void
MergeSort(void...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |