Running code from a button in PHP?
I'm wondeing if someone can help.
What I want to do is the following:
I have a PHP report that shows all comments within an oracle database for a specified date
what i want to do is hide records that have offensive material in them by giving the user the ability to tick a checkbox next to the record and click a button that will then update a field in the database called $visible to a 1 thus hiding it when the report is next generated.
How would i go about linking the button to the code?
<img src="hide.gif" onclick="this.src='hideid.php?id=<?=$id?>'; return false;">
The PHP page shown could also serve up a change in the image to indicate success.
A little more JavaScrpit code could also immediately hide the current table row.
sorry if i sound a bit daft but in the onclick part do i reference the section of code that I would like to run in the $id section?
Also am trying to figure out how to get php to do the following:
$ticked_string = "";
$unticked_string = "";
rowcount = count of rows
for x = 1 to rowcount
if row(x).checkbox is ticked then
$ticked_sting = $ticked_string & row(x).contact_id & ","
$unticked_sting = $unticked_string & row(x).contact_id & ","
$update1_string "update sms_out_audit set visible = 0 where contact_id in (" & $unticked_string & ");"
$update2_string "update sms_out_audit set visible = 1 where contact_id in (" & $ticked_string & ");"
Can you give me any ideas?
The piece of code you wish to run would be in a document called "hideid.php" -- and, obviously, you can use any document name here you wish. The $id part would be an identifier which tells you which section of the report needs to be omitted next time.
it doesn't need to be a button or a post, on each row create a link <a href="hideid.php?id=<?=$id?>">Hide</a> then in hideid.php update the row with the given id and redirect back to the report page
not sure if i have explained myself properly as am still confused
I have a report that outputs comments from an oracle database into a PHP page.
What I want to do is put checkboxes/radio buttons beside each record that it outputs so if an abusive comment comes in I can click the checkbox/radio button next to it, click update and it will hide the record.
To hide it all i need to do is be able to send the value 1 from my result set to a column called $visible in my database and for it then to post back to the same page.
Is it possible?? Am going crazy trying to figure it out
All methods previously described will do that. Take your pick.
could you give me an idea what i should put in my hideid.php? have been working on this all day and have a total mind blank!
Give an example of the database key for the information you wish to hide.
I want to update the $visible column in my database called bblq.sms_out_audit sms with a 1 in order to hide the record
What is the key to that database row?
Cont_id is the db row i need to update
I think i might need to do something like this???
set visible = 1 where cont_id = "" ??
OK, now show the loop where you're reading the database table and writing the rows out to the client.
Ok I have managed to get the code to work but in my hideid.php i cant see how to pull in the contactid? It has it in the address bar but how to i get my code to run so that it just updates the record specified?
You need to use the Querystring variable, PHP isn't really my thing but a quick google gave me this page which seems to be what you're looking for http://vdhri.net/webHostingNews/2005...ng_in_php.html
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)