Notifications in PHP [closed]

0

How about, I'm trying to implement a system of notifications in my web application, I just do not know how to start, I've been googling, waiting to find an answer.

I have a table in MySQL that has the following fields:

id (PK) du_id (FK) first name e-mail comments cv seen.

I want that at the moment that the insert is made to the database with these data, a notification is sent to the owner of du_id as something new alert and the number of notifications to see.

I hope someone can help me, and if you can provide me with a code, I would be very grateful

I'm looking for a code to do something like this

    
asked by Cesar Gutierrez Davalos 04.06.2017 в 23:39
source

2 answers

1

Well mate, you said you do not know how to start, right? Well, this sometimes happens when the objective experience exceeds current knowledge. However, the community in general knows, all that programmer that this feeling is well known when you dedicate yourself to programming, since with the passage of time you want to create bigger things and you are learning more and more, and more and more complex everything. But calm, everything comes to control over time and practice. I will try to help you as I would since I have been able to imagine it in my head as for my own web project. How to implement it?

I would do it in the following way and is thinking about the "route" that the service would perform. The first thing is to divide the complex objective into as many processes as you can and make it easy.

1st create a form in your administration panel

a) In this panel you create a section where there will be a form to create notifications. This implies a form with Campo de texto para tu notificación "INPUT TEXT", campo para referencia id cliente "INPUT NUMBER", b) Fill the 2 data (the message and the customer ID)

c) Then send it to the logic that controls the data of the form.

2º Form data arrive to the controller (logic)

a) First of all we must create the table where we store the notification data, that is, notificaciones_usuarios In this table we will have: id - (incremental unica) para evitar repetir entradas en la base de datos texto (EL FORMULARIO) id_user (EL FORMULARIO) Clave foranea a la tabla usuarios fecha - date() o dia de creación leer (boolean) 1 leido | 0 no leido b) Now if with the data that comes from the form sent, we keep them in this table and the logic that we should do to save them would be. "id" de la notificación será autoincremental desde 1 hasta 99999... "texto" será el que escribamos en el formulario de administración Input "id_user" será el id del cliente del formulario de administración Input "fecha" será la fecha del dia que creamos el mensaje y lo enviamos date() 'leer' es un booleano que por defecto estará en "0" (no leido) y "1" (leido).

3º The views of the client from his user panel (registered and logged) You can place this where you want, as you say above in 1 icon, in the navigation bar you can do the logic of:

* Query to the database: {Busca los mensajes en la tabla "notificaicones_usuarios" con el parametro de "leer en 0" y con la "id de usuario logeado".} And this query you do the typical count (QUERY) and count how many entries with those parameters exist or have obtained with those parameters. That is, how many unread messages the specific client has. And so you paint the shtick on the icon. of client views.

Well up here would be what you want, and so far I offer you because this way of "help" is that some will not agree, because it is "hard / arduous" to read logic, but not forget that the one who is going to read it is the interested one. Being in place 1 year and a half ago ... it would have been good for me to explain something like that when I had my complex doubts as a beginner. And because of that, I help you up to where you directly ask your solution.

Give more personalization to what you ask would seem obvious .. but not necessary in your case, with understanding this logic and achieve it for yourself ... it will be a big step and advance for you. Courage!

I hope you will help Mr. Cesar Gutierrez Davalos; D

PS: The reason for not doing the code is that as you said, you did not know how to start, and here we are to help solve a question or problem, but not to perform all the code of another from 0, with all the respect your question, I understand you and I give you a solution to how to start chopping the code. Simply, now that you have a logic to start programming, try to do it and if you have code problems I invite you to ask again in this community contributing what has already been done by you and thus be able to find the fault / doubt.

    
answered by 05.06.2017 / 02:15
source
0

I do not know how you send data to your frontend, but assuming that you do it by request, you have to do with jQuery or the framework that you use a get to your server, send as parameters the user's id, and return it in response the number of messages you have, and show it

I can not write you a code because I do not know what you use, the idea is that, you have to look for more examples.

    
answered by 05.06.2017 в 00:14