Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am using php for my application and i have 180 vendors registered on my app,each vendor has a unique id which is stored in database.I have to implement a counter that each time a user clicks on a view details button of a particular vendor the counter of that particular vendor is incremented and is shown on the vendor portal of that vendor . I don't have an exact idea how to approach this problem so I can show that how many times the user has clicked the view details button of that particular vendor.Can anyone guide me ?
Since you are using php there is no hard and fast rule to update counter on database. You should create a method that update counter on your database and use ajax to call that function using javascript or when user clicks on view detail then I think the page loads from new url. If this is the case then before rendering the page you should include call a function to increment the counter associated with the vendor in your database.
Create a table in the DB with vendor id and a counter. Each time a user clicks on a view details button of a particular vendor increment the counter, i.e update the counter in the DB using ajax call. Hope you are familiar to call a ajax function and update the DB.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I was just wondering how do I make my website preview some info after the user searches for something stored in the database.
Basic approach for previewing user names as you type in a search bar. For this to work, you will need to use AJAX to query the server and also display the result as a preview for the user to click on if they want, without having to refresh the page.
User types 'Joe' into the search bar
The onChange() even is fired and you query your server with that the user has written "Joe". Keep in mind this query is via AJAX, so as not to force the page to reload.
Server side, you do a MySQL lookup of the table users, where the name is something like "Joe". SELECT NAME FROM USERS WHERE NAME LIKE '%what_you_sent_on_AJAX_request%' LIMIT 10;
The browser receives the response from the AJAX request and displays a nice dropdown with the output of the server. When the user actually click son this "previews" it is in that moment that you would actually reload to the page or take the user to a new page based on what they have clicked on.
That's a very basic approach for it.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I currently have a timer set up on an “admin” page with JavaScript and I want to display that same live clock on the homepage of my website. How can I do this? It’s basically two input fields that display number values. One displays minutes and one displays seconds. The values are updated using buttons which are found on the admin page. What I’m trying to do is display the current time that the clock is showing on the admin page on a separate page. Is there a simple way to do this?
You could store the value of the timer server side and just query it each second to see at what time it currently is. You could also use socket.IO to have real time access to the server timer.
It's impossible. website is connectionless.
You can't push any event to other client page
without client behavior(like button click..)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm currently working on a website which allows the costumer to personally add movies to a database. So I wrote a PHP class which initially loads all the data needed from a database and creating a table which kind of looks like this:
How do I theoretically proceed to make those buttons work(Which, as they change things in a database should "execute" php-functions).
theoretically this is how you should proceed:
First the database piece
you will create 4 fields
each field corresponding to the table header (notice there should be no space in the name of the field) -- movie_id will be numerical, name will be varchar, etc.
Next the code
I take it the second row are all inside tag? if not make it so
Make sure the form method is POST
I recommend making the action of the form go to another page (keeps it clean)
user clicks on "save changes" button
On the other page (specified in form action), you will receive the data in your $_POST var; based on each input's name, this will be accessible in post. So for example, if your input name for "name" field is "movie_name" then this data will be in: $_POST['movie_name']
Store each field's POST data in a variable... i.e. $movieName = $_POST['movie_name'] ---- THIS IS JUST AN EXAMPLE! YOU SHOULD NEVER ACCESS POST DATA DIRECTLY!! YOU MUST SANITIZE/VALIDATE ETC. THIS DATA BEFORE STORING IN DATABASE
Assuming you have a database link already established, simply insert the data into the table you created earlier
Hope this helps you get started!
Best,
-Rush
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have 10 records in json array that comes from api call. But I need to show only 1 record on webpage providing next and previous buttons. So when user clicks on next or previous buttons I need to fetch the next or previous records and display on webpage. Something like viewpager in android or flipview in windows apps.
The reason why I want to store is just to avoid unnecessarily api calls to server fetching record and also pointers to next and previous record.
Is it possible to store those 10 records in some javascript variable and keep iterating when user clicks on next and previous.
Server side I am using laravel 5.2
Of course it can be done. Just format your JSON correctly to hold an array of records, and maintain an index pointing to the current record.
To update the display you can either use pure JavaScript or utilize some kind of MVVM library (for example) like Knockout or Angular.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to implement a counter on a site I am building, so every time someone submits a form on the site, the counter increases for anyone who visits the site. For example, the number will start at 0 and every time someone submits the form, the count will increase for anyone who visits the site.
I know how to manipulate the number via JS/jQuery when the form submission button is clicked. My question is about how to update the number on the site for anyone who visits the site.
The site is currently a static PHP site without a database associated with it.
oh i get it now..
you can do it with a file.
1) create a file called "counter.txt", put it next to your web page put the number zero in the file.
2) get the current count with php: $counter = file_get_contents("counter.txt");
3) add one to the counter file_put_contents("counter.txt", $counter+1);
// put this wherever you want to do your counting
$counter = file_get_contents("counter.txt");
file_put_contents("counter.txt", $counter+1);
echo "You are the $counter person to view this page..";