Current location: Hot Scripts Forums » General Web Coding » JavaScript » edit-in-place problem in AJAX and PHP with while loop


edit-in-place problem in AJAX and PHP with while loop

Reply
  #1 (permalink)  
Old 03-01-08, 02:13 PM
littlegreen littlegreen is offline
Newbie Coder
 
Join Date: Jan 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy edit-in-place problem in AJAX and PHP with while loop

Hi all,
I'm having the problem while using the edit-in-place scripts from internet. It's ok when i just used for one text id, but after i added a while loop because of multiple items and it become only the 1st text id content works. So below here i post a piece of my code, hope any here can help on this. How to do the multiple items with the same id? Please help. Thank you very much.

PHP Code:

while($disp=mysql_fetch_array($disp_de))

{
            
echo 
'<tr><td>';
$dis$disp['pp_photo_desc'];
echo 
"<p id=\"desc\">".$dis."</p>";
cho '</td></tr>';


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-01-08, 04:24 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
hmm, im not familiar with the script, but im pretty sure that the line
PHP Code:

cho '</td></tr>';
#should be
echo '</td></tr>'
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-02-08, 05:51 AM
littlegreen littlegreen is offline
Newbie Coder
 
Join Date: Jan 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
sorry that's a typo there. But does anyone there can help on this problem? Is it possible to edit-in-place works in the while loop with the same id? thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-02-08, 07:07 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by littlegreen View Post
sorry that's a typo there. But does anyone there can help on this problem? Is it possible to edit-in-place works in the while loop with the same id? thanks in advance.
If I'm not mistaken, an id is supposed to be a unique identifier; in other words, no two elements or fields are supposed to have the same id.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-02-08, 11:05 AM
littlegreen littlegreen is offline
Newbie Coder
 
Join Date: Jan 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
thanks End User. ya, i know about it. But I have to echo it out to display so i put it into the while loop. mm.. Is it possible to put the id into an array?
for example,
Quote:
echo "<p id=\"desc_$i\">".$dis."</p>";
But this is what I had tried, and it can't work. Anything I missed? or should I modify inside the js file? Any expert, please guide me. Thanks a lot.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 03-02-08, 01:33 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by littlegreen View Post
thanks End User. ya, i know about it. But I have to echo it out to display so i put it into the while loop.
Well, there's your problem. Doing that assigns it to multiple fields. You can't really violate a basic syntactical requirement and expect things to work properly.

Try incrementing the id in your loop or work from a list.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 03-02-08, 02:54 PM
littlegreen littlegreen is offline
Newbie Coder
 
Join Date: Jan 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
mm..i have no idea but thanks..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem upload image with AJAX mahmoud82 PHP 9 01-20-08 04:08 AM
[For Hire] PHP, Mysql, ASP, AJAX programer t_narendra Job Offers & Assistance 2 05-21-07 10:35 AM
For Hire: Looking for Php, Mysql, Asp, Ajax work (4 years exp.) t_narendra Job Offers & Assistance 2 01-29-07 04:06 PM
[For Hire] Php, Mysql ASP, AJAX programmer t_narendra Job Offers & Assistance 0 11-29-06 07:08 AM
AJAX problem with php dynamic url scott2500uk PHP 3 10-28-06 11:33 AM


All times are GMT -5. The time now is 01:31 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.