Hi, I’m working on eform2db after also trying db2form (which is also very good). I can get inserts and listings to work nicely but I am having difficulty trying to
1. search table for data in a field and get row.
2. display row (populate form?) with some fields editable (Input type?) and some displayed as text (echo?)
3. Edit fields and save to db - update fields.
4. List row to check.
Also my table has nothing to do with user logins or user ids or emails.
I’ve read the dbapi quite a few times - each time i go through it I pick up something else to try, but as yet haven’t ’got it’.
It is possible that I have been staring at it for so long that i’ve become immune to the answer, thinking it is something very difficult when it is probably easy.
I can do mysql queries and basic php, however putting them into snippets or specifically adding to these snippets just isn’t going to plan.
Could anyone please point me in the right direction? or let me know what dbapi function, or web pages to re read.
Thanks.
Malissa
-
☆ A M B ☆
- 1,056 Posts
Quote from: malissa at Dec 17, 2007, 09:43 AM
1. search table for data in a field and get row.
Here is a very basic example of querying a MODx table (SQL) and looping through the result set:
//<?php
// Select all records with the letter "A" in the pagetitle
$sql = $modx->dbQuery('select pagetitle from '.$modx->getFullTableName('site_content').' where pagetitle like "%a%"');
// Loop through records and echo the pagetitle
while( $row = $modx->fetchRow( $sql ) ){
echo $row['pagetitle'].'<br/>';
}
Quote from: malissa at Dec 17, 2007, 09:43 AM
3. Edit fields and save to db - update fields.
You can do this using eForm’s event functions (examples in the eForm docs and the modx wiki) and the DBAPI (SQL Insert/Update statements)
Also, page 1 of this thread shows examples of how to update fields in the database using eForm/eForm2db
thanks pixelchutes for your help.
I understand the $sql dbquery code, but where would I put it and the form (so the user can search for a field) into the example set a few pages back with the venues code?
I have recreated the add/edit venues script changing to my details. I can’t get it to search for the Name (for example) then show the row its there and update the fields if the name is there or insert a new record if it is not.
What is happening is, it is all being treated like an insert, so my primary key field (other than the auto incr field) ie the Name is duplicating on the next line (with some changed other fields) rather than updating.
Am I doing something obviously wrong?
Regards,
Malissa
Your inserting instead of updating issue just sounds like a logic problem to me. How are you determining whether the record already exists? I bet that test is always returning false when you expect it to return true.
Hi everybody,
First of all, E2DB is so great!!! I spent less than an hour to create a registration form for a huge congres. NICE !!
But voilà, my client (is always unsatisfied) would like to have a confirmation page before sending the fields in the data base. A kind of "are you sure your entries are correct", like the thank you page but before sending. After clicking "ok" only the fields would be sent to the db.
I’ve read this thread entirely, the same with Eform (ok, I admit it, have’nt read the 22 pages)and haven’t found anything that could help me, so if somebody could help or redirect me, would be great.
THX for your help
Thx TobyL for your answer. Your solution seems quite intresting, I have to give a try.
But there’s a small bit of code that I don’t understand (i m kind of novice) : the onBeforeFormParse event should call a new snippet with that "function onBeforeFormParse (&fields) ..etc" in it, just like in the post you redirected me?
For ex: [!eFrom ... &onBeforeFormParseForm=`nameOfSnippet`...!] and in the snippet "function onBeforeParseForm(&fields) ..etc". Am I right ?
[[snippetWithEventFunctions]]
[!eForm ... &eFormonBeforeFormParse=`nameOfFunction`...!]
If you read the documentation and examples in assets/eform/docs/eform.htm things will become much clearer.
In your second form you should have a call to eForm2db. I haven’t used this myself and don’t know what eForm events it uses. You may have to adjust things accordingly.
Muchas gracias !!
Much clearer now, going to check the docs...after a short sleep that would be better.
Thx for your help
Ssory for stupid question... but it’s doesn’t work for me (((
I’m tryin’ next code:
[!eForm2db!]
[!eForm? &noemail=`true` &formid=`contact` &eFormOnBeforeMailSent=`eForm2db` &tpl=`contactform` &thankyou=`contactthanks` !]
And create shippet like in first post...
But when click on send... they said me that Fatal error: Call to undefined function eForm2db()...
I’m uderstand that it’s troble only cause itsn’t see function eForm2db( &$fileds) ... but how it fix???