I hope the SQL you've posted is not like the code in your program.   
You have a serious SQL injection problem.  For example, what if $_GET 
['ID'] === '1 OR true'?

Some sample Fade effects can be found here:
http://wiki.script.aculo.us/scriptaculous/show/Effect.Fade

Effects allow you to include callbacks.  You might find "afterFinish"  
to be the most useful. See more about effect callbacks here:
http://wiki.script.aculo.us/scriptaculous/show/CoreEffects

Instructions for doing an AJAX request are here:
http://prototypejs.org/api/ajax/request
... although you may want to refactor a bit and look into the  
Ajax.Updater.
http://prototypejs.org/api/ajax/updater

If you want to fade, you'll need to add ids to each list item, or  
find some other way of passing the element reference to your  
function. Wrap it all together, and your final code might look  
something like this (untested, etc.)

Effect.Fade('id_of_list_element',
   {afterFinish: function() {
       //Do ajax call here
       new Ajax.Updater('id_of_list_master_container', 'hello.php', {
          parameters: 'ID='+id_of_element;
       });
     }
   });

You'd have to somehow tie this behavior to each item.  This would be  
easier to do if you used list items instead of line breaks.

On the subject of refactoring, why repopulate the entire list if  
you're only removing an item?  Why not just remove the item (w/  
Effect.Fade), and be done with it? Sounds like you're creating extra  
work for yourself.


TAG

On May 17, 2007, at 1:46 PM, envex wrote:

>
> Hey,
>
> I'm brand new to AJAX and scriptalicious, so i'm hoping for some help.
>
> inside hello.php
>
> I have this piece of code to grab and loop out users in the database:
>
> function test(){
>      $query = mysql_query('SELECT * FROM `testing`');
>
>      while($i = mysql_fetch_row($query))
>      {
>          echo'<div class="testie">';
>          echo $i[0] . "<br />";
>          echo $i[1] . "<br />";
>          echo $i[2] . "<br />";
>          echo '<a href="javascript: MyAjaxRequest(\'main\', 
> \'hello.php?
> ID=' . $i[2] .'\')">Delete</a><br />';
>          echo '</div>';
>     }
> }
>
> This piece of code deletes the user from the database if chosen, and
> then re-generates the list via AJAX:
>
> if($_GET[ID] == "")
> {
>     echo "nothing";
> }else{
>     $delete = mysql_query('DELETE FROM `testing` WHERE ID = ' .
> $_GET[ID] . '');
>     echo "Item has been deleted";
>     test();
> }
>
> Now comes the problem, how would i make the delete div use the
> scriptalcious fade effect to fade out, then execute the AJAX function
> to delete the user?
>
> Any help is greatly appreciated!
>
> Thanks,
>
> envex
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to