[PHP] form problems

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
I am having trouble with this script:

$quote_result = mysql_query("SELECT * FROM wiki_quotes ORDER BY $submit ASC");
while($quote_row = mysql_fetch_array($quote_result)){
echo "<p class = \"wiki_data\"> <tr><td>" .$quote_row['Quote']. "</td><td>" .$quote_row['Importance']. "</td><td>" .$quote_row['Submitted By']. "</td><td>" .$quote_row['Page']. "</td><td>" .$quote_row['Chapter']. "</td><td><input class = \"wiki_edit\" type = \"submit\" name = \"edit\" value = \"edit\"> <input readonly type = \"hidden\" name = \"hidden\" value = \"".$quote_row['id']."\"></td></tr></p>";
}

The focus here is <input readonly type = \"hidden\" name = \"hidden\" value = \"".$quote_row['id']."\">, because when I get to the submitted part of the form, and I print $_POST['hidden'], the value is always that of the last row retrieved by the loop.

I need the value of $_POST['hidden'] to equal that of the row which the variable was created.



Does anybody know how to do this without me changing the loop? (I need the loop to display all entries, even if some are added without the loop being changed)
 

TheOutfit

New Member
Messages
24
Reaction score
0
Points
0
Dude,
Usa HTTP Authentication script if your trying to secure files
Its ALOT easier & its harder for people to get passwords...
 

bonzo meier

Member
Messages
47
Reaction score
0
Points
6
hi,

maybe you should wrap your input-tags in a proper form tag, as
<form method="post" action="whateveryoulike.php">...</form>

i don´t know if this solves your problem, but at least it´s more correct in html-terms

peace, bonzo
 

VPmase

New Member
Messages
914
Reaction score
0
Points
0
Try setting $quote_row['id'] to a perm var using an if/then statement in the loop then using that perm var in place of $quote_row['id'].

$quote_result = mysql_query("SELECT * FROM wiki_quotes ORDER BY $submit ASC");
while($quote_row = mysql_fetch_array($quote_result)){
if(*equal that of the row which the variable was created*) $permvar = $quote_row['id'];
echo "<p class = \"wiki_data\"> <tr><td>" .$quote_row['Quote']. "</td><td>" .$quote_row['Importance']. "</td><td>" .$quote_row['Submitted By']. "</td><td>" .$quote_row['Page']. "</td><td>" .$quote_row['Chapter']. "</td><td><input class = \"wiki_edit\" type = \"submit\" name = \"edit\" value = \"edit\"> <input readonly type = \"hidden\" name = \"hidden\" value = \"".$permvar."\"></td></tr></p>";
}
 

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
I fixed it...

The problem was I was creating multiple variables of the same name within the same form. Naturally, the one it picks is the most recent one, because creating a new one of the same name would overwrite the old variable. I got that all fixed.


Thanx for all of your help :)
 
Last edited:
Top