Page 1 of 1

how to get the data when there are multiple buttons

Posted: Fri May 16, 2008 6:03 am
by angelina
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??

Re: how to get the data when there are multiple buttons

Posted: Fri May 16, 2008 7:06 am
by highjo
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? :D

Re: how to get the data when there are multiple buttons

Posted: Fri May 16, 2008 7:12 am
by angelina
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

Posted: Fri May 16, 2008 7:26 am
by angelina
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

Re: how to get the data when there are multiple buttons

Posted: Fri May 16, 2008 9:13 am
by nowaydown1
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

Posted: Fri May 16, 2008 10:18 am
by highjo
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.

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]";
}
 
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? :)

Re: how to get the data when there are multiple buttons

Posted: Mon May 19, 2008 6:12 am
by angelina
thanks nowaydown1 n highjo for help!!!

Re: how to get the data when there are multiple buttons

Posted: Tue May 20, 2008 1:25 pm
by highjo
i'm not sure i understand but it's ok :D .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

Posted: Tue May 20, 2008 11:42 pm
by angelina
thanks for ur concern highjo.. i really appreciate it!!!! :)