Create a simple template to display data from a mysql query

Can we see the work ends?

work ends? Do you mean screen shots that show how it's working?

If so, I need to make the output a bit prettier... it's just displaying the results dump of an sql query right now. I'll post those screen shots later this afternoon. Where there's a will, there's a way... usually lots of ways :cool:
 
Ok, here it is.... No Add-On, No Callback, dumping the results of a query into an XF page

FYI: Here is the sql statement that I used to generate the list
<table border=1 cellspacing=1 cellpadding=1>
<tr><th>Event</th><th>Date</th></tr>
<xf:foreach loop="$xf.app.db.fetchAll('SELECT event_name, event_date FROM event_data')" value="$row">
<tr>
<td>{$row.event_name}</td>
<td>{$row.event_date}</td>
</tr>
</xf:foreach>
</table>

Screen shot of output
ss1_events.jpg


Like I said.... no Add-On, no Callbacks... not even a template. Simple. Each of those menu items have different sql queries.

I think you have got me started in the right direction.
Kirby: I don't think so, but we'll see.

sql query: with the initial of how to do the query from Kirby - Thank You.
 
Last edited:
Ok, here it is.... No Add-On, No Callback, dumping the results of a query into an XF page

FYI: Here is the sql statement that I used to generate the list


Screen shot of output
View attachment 279597


Like I said.... no Add-On, no Callbacks. Simple. Each of those menu items have different sql queries.
sql query, with the help from Kirby - Thank You.
That`s very nice :)
Congrats!
 
Ok, here it is.... No Add-On, No Callback, dumping the results of a query into an XF page

FYI: Here is the sql statement that I used to generate the list


Screen shot of output
View attachment 279597


Like I said.... no Add-On, no Callbacks. Simple. Each of those menu items have different sql queries.




sql query: with the initial of how to go the query from Kirby - Thank You.
What code did you put in the "add new event " page?

This is useful. Cannot comment whether it's the best method, but an efficient way to do this would be so useful as a resource as a how to by by a xf developer.
 
What code did you put in the "add new event " page?

This is useful. Cannot comment whether it's the best method, but an efficient way to do this would be so useful as a resource as a how to by by a xf developer.
It's nothing more than a form to get the name of the event, and the date, and then it writes it back to the events table. There are other options like "clone a past event", etc but basicially, add the event and date to the database.
 
my sql is:
<table border=1 cellspacing=1 cellpadding=1>
<tr><th>Event</th><th>Date</th></tr>
<xf:foreach loop="$xf.app.db.fetchAll('SELECT event_name, event_date FROM event_data')" value="$row">
<tr>
<td>{$row.event_name}</td>
<td>{$row.event_date}</td>
</tr>
</xf:foreach>
</table>

The date (in red) displays as 2022-05-20 00:00:00
Does anyone know the XF syntax to display this date as Y-m-d ?

I have tried all types of things and can't get it to display correctly.
Last attempt was: {{ date($row.event_date, 'Y-m-d') }} but it always dislpays the same date - 01/01/1970
In the mysql database. it's stored as datetime and looks exactly like it's displaying - 2022-05-20 00:00:00

Any help here?
 
  • Like
Reactions: eL_
You need a unix timestamp as input, eg. UNIX_TIMESTAMP(STR_TO_DATE(event_date))

Thank you... didn't really need the"str_to_date" - it was declared as datetime in the db.
Just needed "unix_timestamp(event_date)"

New Screen shot after date converted

.
ss1_events.webp
 
Top Bottom