943,104 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 422
  • PHP RSS
Feb 9th, 2010
0

functions using tables

Expand Post »
hi guys, just wanna ask, is it possible to have a function using tables in html wherein if a user selects a row, the program will get the value of the entire selected row? and this value will be passed to php without reloading the page itself..thanks thanks in advance,^_^
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster
xuexue is offline Offline
165 posts
since Jul 2009
Feb 9th, 2010
0
Re: functions using tables
Yes, all you need to do is give each row a unique id (eg number) and use ajax to make the php request.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,003 posts
since Sep 2007
Feb 9th, 2010
0
Re: functions using tables
could you give me some code in there??
Reputation Points: 10
Solved Threads: 1
Junior Poster
xuexue is offline Offline
165 posts
since Jul 2009
Feb 10th, 2010
0
Re: functions using tables
This is a brief code...
PHP Syntax (Toggle Plain Text)
  1. echo '<table border=1 cellpadding=5 cellspacing=0>';
  2. for ($i=0;$row=mysql_fetch_assoc($sql_result);$i++) {
  3. echo '<tr id="'.$i.'">';
  4. echo '<td>'.$row['column1'].'</td>';
  5. echo '<td>'.$row['column2'].'</td>';
  6. echo '<td><a href=# onclick="javascript:ajaxfunction(\''.$i.'\');">Send</a></td>';
  7. }
  8. echo '</table>';
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,003 posts
since Sep 2007
Feb 10th, 2010
0
Re: functions using tables
sir, the code didnt work, it displays an error "Object required."
Reputation Points: 10
Solved Threads: 1
Junior Poster
xuexue is offline Offline
165 posts
since Jul 2009
Feb 10th, 2010
0
Re: functions using tables
My code was just a brief outline that shows the hard stuff but all you need to do is create the ajax function with the row input and to do the mysql query. I would suggest following an ajax tutorial for that bit so you can get an understanding of how it works.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,003 posts
since Sep 2007
Feb 10th, 2010
0
Re: functions using tables
Possibly the error "Object required." will comes if you haven't created instance for the database or if you haven't created XMLHTTPREQUEST Object.

If you haven't created Ajax object then
javascript:ajaxfunction
will not works for you.

cwarn23 has given correct code for you.
Reputation Points: 16
Solved Threads: 28
Posting Whiz in Training
saiprem is offline Offline
209 posts
since Feb 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Replace a string in textfile using php
Next Thread in PHP Forum Timeline: finding the sum inside a loop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC