mysql database - output one name in page. after refresh page - next name outputs

Hello!

Sorry for my bad english, I hope you’ll understand me

So, I have table with values:

id candidate_name candidate_surname candidate_faculty

ожно их вывести по одному (допустим по id, до последнего), и по нажатию той или иной кнопки (в скрине лайк или дислайк) он отбрасывает обратно на ту же страницу, но выводит уже следующего кандидата?

Is there way to output from database by one user in time (example: id) and after pressing the button (in screen like or dislike) it goes to next page where writes this candidate information, student who voted and most important the value (like or dislike).
After the information is written in other database, it returns to the first page but now output the second candidate…

I can’t put screen, but there is simple table with name, surname, faculty and two buttons - like and dislike

Hope you can help me

Your english is fine, but there is not much information in here about what you have done, and what you need help with.

There are many rating scripts available
http://www.hotscripts.com/category/scripts/php/scripts-programs/reviews-ratings/

And lots of tutorials about building a ratings system:
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&es_th=1&ie=UTF-8#q=create%20a%20start%20based%20rating%20php

Thanks, but for me it isn’t good enought!

Well, then I’ll try to explain from beginning.
So, I need to make online voting. Student can login and vote for candidates (they will be around 20-40)

I have the table that outputs the candidate information: (screen 1)

And there is textbox, button or just link (ANYTHING)… You press, and if it is ‘+’, then all information about candidate should be written in another database with value ‘+’…
Information is written, but it goes back to to list and outputs the SECOND candidate (name3, surname3 …), and you can vote…
AND AGAIN (candidate_name4, candidate_surname4)
and it print’'s candidate one by one after pressing the ‘ANYTHING’ key…

and my question is:

how to make query that output first candidate,
after pressing the button - writes in another database
and prints the second candidate
and so one untill the last is given


Untitled.png

There is a section on the forum if you want code written for you.
I’m not sure what your experience level is. From the sounds of it, you may wish to start with an existing polling / voting code.

“id” is a troublesome field name with reserved names and such, candidate_id would be better.

You will also need a field or table for keeping the values. You need to decide if you are recording a quantity (1/-1) or you need a separate table to log votes.

I’ve done the 95% of work…

All I need:

Print the candidates from one database

Where each name has
*) button
*) images with ‘like’ and ‘dislike’
*) textbox where you can write ‘+’ / ‘-’
*) with option
*)

anything where I can write ‘+’ or ‘-’
and by pressing the button
it write to ANOTHER database, like you said

I don’t know how better record ‘1’ and ‘-1’ or with ‘+’ and ‘-’,

for now, All I need is that student can login and vote for each student give him ‘like’ or ‘dislike’

First Step I see is that you still need:

-Create/Register a login
-Login and validate credentials
-Store Votes

So you need a table for logins
-student_id
-username
-hashed_password

You need a table for votes
-id
-candidate_id
-student_id

-vote

I have all tables, all validations…

Maybe you didn’t understand mee…
I just need the idea how to print from one table:

*) Candidate name
*) candidate surname
*) candidate faculty

and with HTML add to all candidate ‘+’ or ‘-’ (decides student)

There is no difference how to print - with one student or all students in one time

I just need algorithm that reads from one table and WRITES to ANOTHER TABLE all information about CANDIDATE and ADDITIONAL information is: student_name (get from $student_name = $_SESSION[‘student_name’]:wink: and value: (’+’ or ‘-’) depends on what student choose to certain candidate

Ahh, I don’t know how else to explain…
I just really need this solution,
I’m already going crazy ;c

Maybe you didn’ undersand me

Maybe you could let me know what level of programming knowledge you have, and what part you are having trouble with.

About you:
Do you know how to connect to the database and do a select or insert statement?

About the project:
What programming language?
What is the table that stores the vote and the student id?

#psuedo-code

if isset post[candidate] and isset post[vote]
    insert into voting table candidate, student, vote.

Basic php + mysql… Nothing extra like functions and class - haven’t got so far

Yes, I know insert, update database… How to connect…

What programming language?
php+mysql
What is the table that stores the vote and the student id?
the student table:
student_id
student_name
student_password
status- if student didn’t vote - student=0; , if he has vote - status=1 (later it changes with update query)

table that stores the vote
this table is empty…
I thought after pressing the button in this table will be written only student_name, all information about candidate and result (’+’ or ‘-’)

but how to do loop, that provides each student can vote for each candidate with value ‘+’ or ‘-’ THAT IS WHAT I CAN’T FIGURE OUT

So you may need to do some studying before any of this makes sense.

So you know how to to get the form values.
In the form, you place the candidate_id, and an checkbox for vote

When you process the form
-Check for the post variables (isset($_POST[‘candidate_id’]))
-Check for the vote (if you use on checkbox, the value will be on/off)
-Insert the vote, using the session variable for the student.

-If the insert was good, do a select to find your next candidate, and user a header redirect to go to the next candidate, which should be your incremented candidate id.

If you are still having trouble code, you can try posting what you have tried, and someone can look at it.

Sponsor our Newsletter | Privacy Policy | Terms of Service