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.
[02:56 pm]
Oh_Man -- long story short - patience is a virtue!
[02:56 pm]
Oh_Man -- and i went on to win the tournament, and a pair of steelseries headphones. i even reember how i won the final match - hallucinated a fck-tonne of units and my opponent thought i had way more than he did and GGed
[02:55 pm]
Oh_Man -- but the net dropped for the longest time, and he got pissed and left. Then, 10 min later - net came back on and tournament resumed
[02:54 pm]
Oh_Man -- basically, i went to a LAN where a pro SC2 player was also at Iaguz, to compete in SC2
[02:54 pm]
Oh_Man -- NudeRaider
NudeRaider shouted: Oh_Man how many GSL titles?
none
[2026-8-03. : 12:56 am]
Symmetry -- It is not! the working title atm is "Road to SENCON 2026"
[2026-8-03. : 12:31 am]
l)ark_ssj9kevin -- reindeer breeding 3???
[2026-8-02. : 10:43 pm]
Symmetry -- No, I have another map in the works that does tho
[2026-8-02. : 9:55 pm]
l)ark_ssj9kevin -- are there EUDs now?
[2026-8-02. : 5:14 am]
Ultraviolet -- 🔥
Please log in to shout.


Members Online: lil-Inferno