how to get the data when there are multiple buttons
Moderator: General Moderators
how to get the data when there are multiple buttons
hi.. i am not tat familiar wit PHP.. here is my problem..
i have to prints some thing like this-
TEXT 1 vote up vote down
TEXT 2 vote up vote down
TEXT 3 vote up vote down
TEXT 4 vote up vote down
TEXT 5 vote up vote down
i am using a loop to print all that is in red.. while i do this.. i am displaying the buttons too in the same loop.
now how do i get the data when that button is clicked??
i have to prints some thing like this-
TEXT 1 vote up vote down
TEXT 2 vote up vote down
TEXT 3 vote up vote down
TEXT 4 vote up vote down
TEXT 5 vote up vote down
i am using a loop to print all that is in red.. while i do this.. i am displaying the buttons too in the same loop.
now how do i get the data when that button is clicked??
Re: how to get the data when there are multiple buttons
I think your post is a little hard to follow or understand.what is in red are text and what is in blue are buttons?What are text are printed by a loop right?So you want to click on a button to make something appear right?If you know javascript and a little css you can do it.for now try to be explicite to have answers.ok? 
Re: how to get the data when there are multiple buttons
yup.. sorry i forgot to mention that.. ones in blue vote_up vote_down are the buttons..
Re: how to get the data when there are multiple buttons
yes the text is in the loop.. n the buttons are also printed in the same loop..
say.. if button vote_up is pressed for Text_1 i will have to insert some changes in the DB.. how do i get that its the TEXT 1
say.. if button vote_up is pressed for Text_1 i will have to insert some changes in the DB.. how do i get that its the TEXT 1
-
nowaydown1
- Forum Contributor
- Posts: 169
- Joined: Sun Apr 27, 2008 1:22 am
Re: how to get the data when there are multiple buttons
One way would just be to set the value of your vote_up, vote_down buttons to something relevant to what your text is:
Code: Select all
TEXT 1
<input type="submit" name="voteUp" value="Text1" />
<input type="submit" name="voteDown" value="Text1" />
TEXT 2
<input type="submit" name="voteUp" value="Text2" />
<input type="submit" name="voteDown" value="Text2" />
Re: how to get the data when there are multiple buttons
if the db from where you are fetching the data for text has a unique field lest's say id then it would be simple.you have to create a new file to do the edit or the database update part for you.Do you know about query string?if yes you should understand what i'm going to tell you if not you have to post you code so that i can see it right?
ok let's back to the explanation.
in th loop i want you to remove the buttons and print html links i mean the <a></a> stuff for each text ok?
after that in your query to select the text select a field that uniquely identify your text.i assume the field name to be id.
then in the file updatefile should be the one that would process the update part of the work with the query that is suppose to be executed.
If it is buttons i suppose you would echo <form></form> element for each.then in the action you do the same query string.we cool?
ok let's back to the explanation.
in th loop i want you to remove the buttons and print html links i mean the <a></a> stuff for each text ok?
after that in your query to select the text select a field that uniquely identify your text.i assume the field name to be id.
Code: Select all
while($row = mysqli_fetch_array($query))
{
//this is for explantion purpose only right?
echo " <a href='updatefile.php?id=$row[id]'>$row[text]";
}
If it is buttons i suppose you would echo <form></form> element for each.then in the action you do the same query string.we cool?
Re: how to get the data when there are multiple buttons
thanks nowaydown1 n highjo for help!!!
Re: how to get the data when there are multiple buttons
i'm not sure i understand but it's ok
.It seems you don't speak english.If you speak french and still having problem, you can write a private message to explain your problem and i'll reply in french for it.
Re: how to get the data when there are multiple buttons
thanks for ur concern highjo.. i really appreciate it!!!! 