Re: Arrays and forms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello list,

I submitted this problem earlier but got no response so I thought I'd
elaborate.

The code below successfully displays all of the problems from the db. 
Based on what is chosen here, needs to go into another table in the db 
along with a customer tracking id.

for($knt = 0;$row = mysql_fetch_row($res3); $knt++)
	{
	$cat_detail = $row[0];
	echo "<tr><td><input type=\"checkbox\" name=\"prob[]\" value =
	\"$cat_detail\"></td> <td> $cat_detail </td>"
	."<td> High <input type=\"checkbox\" name=\"level[]\"
	value=\"1\"></td>"
	."<td> Med <input type=\"checkbox\" name=\"level[]\"
	value=\"2\"></td>"
	."<td> Low <input type=\"checkbox\" name=\"level[]\"
	value=\"3\"></td>"
	."<td><center><input type=\"checkbox\" 	name=\"yes\"> Yes
	</center></td></tr>";
	}

When this page is submitted, I can successfully capture $prob[]  - but I
am having no luck in pulling the corresponding $level[] (if one was
checked).  So my form - once submitted - may look like:

Problem one		(no priority picked)
Problem two		High priority
Problem three		Low priority

My $prob[] would be:		My $level[] would be:

$prob[0]: Problem one		$level[0]:	High
$prob[1]: Problem two		$level[1]:	Low
$prob[2]: Problem three

So as you can see my second problem does not correctly correspond to the
correct priority.  The first (or all) element(s) in the level array may
be null.

I have read up on and tried some associative arrays but no luck in
utilizing them within a form; been trying all sorts of testing, books,
web tuts, etc. but still come up with the same problem.  

Also in case anyone were to suggest sessions, my supervisor is adamently
opposed to using them on this site, not sure why, not even sure if that
would make my life easier or not since I've never used them.

Any comments (good, bad, indifferent) here would be most appreciated. 
Any suggestions as to other ways of doing this also appreciated.

Many thanks 

Mignon


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux