I have a database table called quotes.
I would like to load a random quote from the table and after 5 seconds, have it fade out and fade in a new quote derived from the DB.
Database Layout for table 'quotes'
ID | Author | Quote
For general case:
In Back-end: Create a route which returns a random 'Quote' record.
In Front-end: Create an ajax call to the route every 5 second.
Related
How to combine POST and UPDATE commands in one action in laravel 8 with ajax?
I have one column "status" in another table that I need to update when I save the data.
In this case basically I have two different tables... thank you for your answer!
Update from the comments:
I have two different database tables, let's say the "Quotation" and "Detail Quotation" tables, where in the "Detail Quotation" table there is a Status column that contains TRUE or FALSE...
Well, I want when I add data to the Quotation table, I also run the command to change the contents of the status column in the "Detail Quotation" table.
you must use observer for this case
https://laravel.com/docs/8.x/eloquent#observers
When you save the POST data in table. Laravel return ID then, with that ID you can call the update function for another table to update the status.
Let's imagine we have a web-page with the content and one of the elements is table where we have couple of columns. It is done with Joomla, so basically I am working with the web-page constructor if I can call it like this and not with code. In the last column I have a link with query parameters, so something like this: link?qparam1=sth1&qparam2=sth. The values for these query parameters should be taken from the first and second column and inserted in this link. Otherwise I need manually to copy those values to each and every link which makes in very slow and inefficient especially when table values are changed, the link must be updated as well.
Is it possible to fetch the data from columns and include into the link?
Write a system plugin, Get data from a table, insert/update data to request
$app = JFactory::getApplication();
$app->input->set('qparam1','<value from table>');
it will update request data.
I am writing a Joomla 3 component and new to the Joomla framework.
I need to insert data into two tables.
the logic follows
insert form data into table after submit
retrieve data for next insert ( i can do this and i have the data array )
insert data from array into second table with the PK of the first insert from step 1.These tables are related by 1-M
return the user back to where they came from with success.
I think i have to override the save method in my model to do this but i don't understand how to get the pk of the first save to use with the 2nd
Due to my lack of understanding I am not sure of best practice in this situation.
after reading there is a postSaveHook() method but I am do not understand how to access the data as it returns void
If i copy the Joomla parent save Method and override in the model it will return Boolean therefore i don't no how to access the last PK from the first insert / save.
thanks in advance for any advice.
I have 3 tables I am trying to join.
user
photographer
gallery
They all share the same identifier column user_id.
When I do a select, there is one record in the user table, one record in the photographer table and currently 5 records in the gallery table.
I would like to retrieve just one row back, but containing the 5 results out of the gallery table.
I tried the following but it returned 5 separate rows.
$this->db->select('*');
$this->db->from('user');
$this->db->join('photographer', 'gallery.user_id = photographer.user_id');
$this->db->join('gallery', 'gallery.user_id = users.id');
Basically, every photographer has a user entry, but they may have multiple images stored in the gallery table.
I only require one result per photographer, but need the 5 images too.
Any ideas? Thanks in advance.
You have 2 options as I see it:
Use 2 queries: one for the tables user and photographer where it will return only one record and the second query to retrieve the images.
Leave the query as it is and list the user + photographer from the first row and loop all the rows to list the images.
Note: I prefer using the first method, although it adds more queries to my application, but this way it's very clear what I have intended and other programmers will find it easier to modify my script.
I'm come from a .net background to grails. I got a form for user to insert, and a html table with the list of records. Once user insert a new record, how do I update the html table with the record and display a message - e.g. company inserted?
Create a domain class for inserting your records, with whatever properties you need. Read Creating domain class and Grails GORM
Once the user submits your form insert the necessary values as a record into this. For getting the entire list of records you can call the list() method on your domain-class. Send the entire list of records to the client side as the response of the action / render as a model. See render. Update your html table using these new records.
For the status part, you may want to do the insert operations in a try-catch block and render a status a message accordingly.