PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Mon May 29, 2006 10:33 am
Hi,
i was wondering,what code would i use to make a dynamic button that,when pressed,will do soemthing for that entry?
i want these to be retrieved from the database. So i call them and put them into an array,my question is,how would i make the value go into a button?
Code: Select all
while($array = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo '<input name="validated" type="submit" value="Validated"' />//im not sure what to put here
}
i think i am going along the lines of what i need to do but i need to know what to do at the commented area so that i can use the value of $array['remove'] there.
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon May 29, 2006 10:36 am
Code: Select all
while($array = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo '<input name="validated" type="submit" value="Validated"' />//im not sure what to put here
}
Are you just trying to do this:
Code: Select all
echo '<input name="validated" type="submit" value="' . $array['remove']. '"' />//im not sure what to put here
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Mon May 29, 2006 10:41 am
yep,that seems almost what i want to do,i want to pass the value to another script,wwith an action also. Would it be liek
Code: Select all
echo '<input name="validated" type="submit" value=remove.php?action=remove&"' . $array['remove']. '"' />//im not sure what to put here
like that?
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon May 29, 2006 10:44 am
No,
You need to put the action in the form element:
Code: Select all
<form action="remove.php">
<?php
while($array = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo '<input name="validated" type="submit" value="' . $array['remove']. '"' />
}
?>
</form>
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Mon May 29, 2006 11:38 am
so then in the value,all i put is a
Code: Select all
<form action="remove.php">
<?php
while($array = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo '<input name="validated" type="submit" value="'?action=remove . $array['remove']. '"' />
}
?>
</form>
wont that be something like it because i want all of the entrys to be sent with the action remove so i i can do that in my next script.
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon May 29, 2006 11:45 am
If you want the value sent to be named: action
Then change the name of your button to: action
/* When doing stuff like this some people store the value in a hidden field and set the desired value via javascript.
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Mon May 29, 2006 11:55 am
I thought of a simpler way to do it. Can i jus make them as links?
Would this make the link,assuming that i have the $array working?
Code: Select all
echo '<tr><a href=do.php?act=approve&entry='.$array['id']>Approve</a></tr>;