sr1200
-
Posts
3 -
Joined
-
Last visited
Never
Posts posted by sr1200
-
-
Ive been pulling out hairs trying to get a piece of code to work.
I have a document repository that users upload files to. The files are uploaded to the appropriate folder and a record is added into the database that indexes when where by whom it was put as well as a flag for "public or private"
I got the upload portion of my program working great, now its time to display the documents that people have uploaded.
EX of database:
ID | name | file_name | file_flag | dept |
1 Bob info.txt 1 IT
2 Steve hex.doc 0 Exec
3 Sarah help.txt 0 IT
4 Tom help.txt 1 Acct
What i need to do is be able to display the data grouped by department,
so ex:
IT
info.txt
help.txt
Exec
hex.doc
Acct
help.txt
I created an sql query that counts the number of documents in each dept and returns only one value of each dept. ex:
IT - 2
Exec - 1
Acct - 1
So now i have a While statement that prints out each dept in teh database once.. (GREAT!)
however, i then cannot for some reason create another While statement WITHIN the first WHILE statement to matchup the files with the dept. heading.
I readup on some things regarding foreach, but couldnt get anything to work properly. If anyone has any example code snips that can point me in the right direction would be much appreciated. -
Really simple... this works with mysql (yeah yeah... i know i dont have the luxury of using mysql at this job)
I have a form field called (for example) f_name
i have code for that field
[code]<input name="uid" type="text" id="uid" value="<? echo $uid; ?>" maxlength="30" />[/code]
see that value=echo thing....
before anythin is posted, i am getting an error saying that the variable is undefined
Once i clear that out and post something everything is fine.
Is there anyway to get that to not error out?
I need the default to echo the input of the user for error checking. (do i have to just make a separate form for this purpose... :(
Thanks
Nesting Problem?
in PHP Coding Help
Posted
I'm going to assume that you are using MySQL, however if not you can work this around to your needs
[code]$docs = mysql_query(..." ORDER BY dept");
$cur_dept = "";
while($row = mysql_fetch_assoc($docs))
{
if($cur_dept != $row['dept'])
{
print $row['dept'] . "<br />";
$cur_dept = $row['dept'];
}
print $row['file_name'] . "<br />";
}[/code]
[/quote]
YOU ARE THE MAN!!!!
Worked Perfectly, just gotta format a bit, but thats it spot on! Thanks so much! [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]