Staredit Network > Forums > Technology & Computers > Topic: "Delete Shouts"
"Delete Shouts"
Jul 16 2009, 9:08 pm
By: Devourer  

Jul 16 2009, 9:08 pm Devourer Post #1

Hello

Hey everyone,
I've coded a shoutbox with features like colors and stuff. What I want to do is that a "X" (picture) will appear in front / behind each shout that will "onclick" (there is an onclick function for pictures) delete that shout.
The problem is I don't know how to directly make it, best way I do not get linked to another page. The shoutbox is inside of a frame, and inside of the frame there is an iframe for the shouts (listed).
I know the "delete" code for the mysql tables, but I don't get how to use it for a listed table. The table "shouts "got the columns ID, user, color, shout.


Can someone help me out?



Please report errors in the Staredit.Network forum.

Jul 16 2009, 10:10 pm DT_Battlekruser Post #2



The onclick field is a JavaScript action, and therefore not capable of accessing PHP through the standard CGI interface. What you need if you want to not reload the page with a form submit button is AJAX. Essentially what this does is sends an XHTTP request behind the scenes and PHP can return something to this request using echo.

As far as deleting from a table, each should should have an ID number that is an entry in the table. Then you do DELETE FROM ... WHERE shout_id = id

You need a separate .php file for the ajax request, so the AJAX request in the JavaScript looks something like

Code
var addr = "ajax/delete_shout.php?id=" + id;
xmlhttp.open("GET", addr, true);


I know this is a little spotty in terms of help, but the AJAX tutorial is pretty good.




None.

Jul 17 2009, 3:17 am Corbo Post #3

ALL PRAISE YOUR SUPREME LORD CORBO

What I do is make it a form and assign that form the desired action, you know.
<form action='blah.php'></form>

You could either make the "X" a submit type button or you could make the "X" a link (like I assume you have it as right now) and do onClick="javascript:document.form.submit();"

I do form cause I also send in other hidden data for later permissions check and verification, you could easily just directly link to the action.

If you have the shouts in an iframe, only the frame will reload.



fuck you all

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[05:59 am]
NudeRaider -- *is
[05:17 am]
NudeRaider -- despite all its flaws the sound design its fantastic
[10:29 pm]
Oh_Man -- homeworld 3 = massive disappointment
[2024-5-14. : 10:05 am]
Moose -- ya
[2024-5-14. : 5:23 am]
zsnakezz -- yes
[2024-5-12. : 8:51 pm]
l)ark_ssj9kevin -- Are you excited for Homeworld 3?
[2024-5-12. : 8:44 pm]
l)ark_ssj9kevin -- Hi Brusilov
[2024-5-12. : 4:35 pm]
O)FaRTy1billion[MM] -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
my server that was hosting it died
[2024-5-10. : 8:46 pm]
NudeRaider -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
https://armoha.github.io/eud-book/
[2024-5-10. : 8:36 am]
Brusilov -- Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
Please log in to shout.


Members Online: 8carolinec541fh4, Vrael, Oh_Man, belzusqeuf