Hey,
I have a page (id 1) and a list of items which are displayed on it (id 2, 3, 4...).
I'd like to create one button for each item that creates a new line in the table called "test" in my database. I just created this table in PhpMyAdmin.
The first column of the new line should contain a unique id. I can handle it in Phpmyadmin.
The second one should contain the result i get from my snippet using $username = $modx->getLoginUserName()
The third one should contain the id of the item i just clicked.
Can anyone please tell me what is the bit of code that will allow me to do this ?
Thx a lot
[ed. note: youfff last edited this post 14 years, 3 months ago.]
-
☆ A M B ☆
- 24,524 Posts
I presume this is Evo (1.0.x).
Use eForm. Submitting a form gives you the $_POST to work with. You can either get the username on submission, or load it into a hidden field when generating the form.
Thanks for answering, Susan. This is Evo, indeed (1.0.6).
Basically, using eForm is what I planned to do first.
But the problem is that I have several items on the same page (=> several eForms), and I couldn't make it work because of that.
Fatal error: Cannot redeclare sendtodb() (previously declared in ...
[ed. note: youfff last edited this post 14 years, 3 months ago.]
-
☆ A M B ☆
- 24,524 Posts
You need to wrap that function in a conditional so it won't redefine it if it's already defined.
if (!function_exists('sendtodb')) {
// function code here
}
[ed. note: sottwell last edited this post 14 years, 3 months ago.]
It should be available as
After a whole day trying to do this, I'm afraid it's impossible...
Does anyone has another idea of how to create a button that gets the id of an item in the database ?
How are you putting the forms on the page? Ditto? A snippet with getChunk()?
If it's a snippet, post it here.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html