[pmwiki-users] updating (MYSQL) tables

Ben Stallings ben at interdependentweb.com
Tue Nov 6 13:51:13 CST 2007


Sjaak van Werkhoven wrote,
> I have got a problem with selecting data from an SQL table. This table is
> filled with new data using one form
> 
> (:update form table=protocol
> fields=voorwaarde,conclusie,documentatie,akkoord,conc_sterkte,user
> submit=post:)
> (:input hidden user value={$Author}:)
> ||class=firstrow border=0 cellspacing=22 width=40%
> ||! Voorwaarde ||! Conclusie ||
> ||(:update textarea voorwaarde rows=3 cols=50:)|| (:update textarea
> conclusie rows=3 cols=50:)||
> ||class=firstrow border=0 cellspacing=22 width=25%
> ||!Documentatie:    ||(:update file documentatie rows=1 cols=30:)||
> ||!Conclusie sterkte:||(:update select conc_sterkte from=concl_sterkte:)||
> ||!Akkoord:   ||(:update radio akkoord Ja:)Ja (:update radio akkoord Nee
> checked=1:)Nee||
> ||(:update submit value="Submit Changes":)||[[
> http://192.168.42.109/pmwiki/pmwiki.php?n=Main.HomePage?action=logout|Uitloggen]<http://192.168.42.109/pmwiki/pmwiki.php?n=Main.HomePage?action=logout%7CUitloggen%5D>
> ]
> (:update end:)
> 
> and should be updated using another form:
> 
> (:update form table=protocol
> fields=voorwaarde,conclusie,documentatie,conc_sterkte,akkoord, user
> required=voorwaarde where=voorwaarde method=get:)
> ||border=1
> ||!Voorwaarde ||!Conclusie ||!Documentatie ||!Sterkte ||!Akkoord ||!User ||
> ||(:update text voorwaarde value={$voorwaarde}:)||(:update text conclusie
> value={$conclusie}:)||(:update text documentatie
> value={$documentatie}:)||(:update text conc_sterkte
> value={$conc_sterkte}:)||(:update text akkoord value={$akkoord}:)||(:update
> text user value={$user}:)||
> (:update submit value="Submit Changes":)
> (:update end:)
> 
> As you can see I had trouble with filling the last form with the data from
> the SQL table. Can someone tell me how to get this data available within the
> last form? Is there a possibility to get more examples using MYSQL tables
> within wiki pages? I

Hi, Sjaak.  It's been a while since I worked with UpdateForm -- I mainly 
use DataQuery now -- but I'll do my best to answer your question.

As far as I can recall or judge from the documentation, UpdateForm does 
not use page variables like {$var} to display data; it only uses 
(:update:) tags.  So your second form should use the (:update:) tags as 
they appear in your first form above, without specifying the values, 
because (:update:) tags automatically display the values from the 
database record.  By specifying values that are not defined I believe 
you are confusing the issue.

The first form, if it is to insert data only and not update, could use 
(:input:) tags instead of (:update:) (with the exception of (:update 
form:)).  This will ensure that you can use the same form repeatedly and 
get a new record each time.  Your second form (once it is fixed) will 
also be perfectly capable of adding new records if you just don't 
specify a record ID (in this case voorwaarde), but once it has been 
submitted the new record will be displayed, which may not be the 
behavior you want.

Note also that your first form above says submit=post instead of 
method=post, and the second says method=get.  UpdateForm only accepts 
data submitted by method=post.

I hope this helps.  If not, send me the URL of your site and I'll take a 
look.  --Ben S.



More information about the pmwiki-users mailing list