473,387 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Hot to plus the vote score into data base

62
Hello,
I have problem to add vote to the data base . In the form i have radio button to choose to rate the score 1 2 3 4 5 ....and when i click to submit this the score in database is changed by the score i chose but it not plus it selv....what should i do.

here is my code :
Expand|Select|Wrap|Line Numbers
  1. $id_vdo=$_POST['id_vdo'];
  2. $name_vdo=$_POST['name_vdo'];
  3. $rate=$_POST['rate'];
  4.  
  5. include "connect.php";
  6.     $sql = "select vote from vdo where id='$id_vdo'";
  7.     $result = mysql_db_query($dbname,$sql);
  8.     $r=mysql_fetch_array($result);
  9.                 $org_vote=$r[0];
  10.         $org_vote++;
  11.         $sql="update vdo set vote='$org_vote' where id='$id_vdo'";
  12.         $result=mysql_db_query($dbname,$sql);
  13.  
  14.  
  15.  
Actually I think this is wrong because i dont know how to plus the new vote with the vote in database and make it change properly.

thanks
Paitoon
Sep 20 '07 #1
5 1546
pbmods
5,821 Expert 4TB
Heya, Paitoon.

Try this:
Expand|Select|Wrap|Line Numbers
  1. $sql="UPDATE `vdo` SET `vote` = `vote` + 1 WHERE `id` = '{$id_vdo}' LIMIT 1";
  2.  
Sep 20 '07 #2
ronverdonk
4,258 Expert 4TB
According to your post you want to update the value in the database with the chosen value, i.e. 1-5. So you increment the count with the selected value (1-5). You do that by statement
[php]$org_vote+=$rate;[/php]
But what I do not see is the number of votes increasing. When you want to calculate an average vote, I think you have the total number of rates divided by the number of votes. So if you have 3 votes, e.g. rates 2,3,5, and a total of 3 votes, the average vote would be 3.3.

Ronald
Sep 20 '07 #3
pbmods
5,821 Expert 4TB
Heya, Paitoon.

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Sep 20 '07 #4
pbmods
5,821 Expert 4TB
Merged duplicate threads.
Sep 20 '07 #5
paitoon
62
Very superb
thanks so much :-)
PAitoon
Sep 21 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Otis Green | last post by:
Vote for or against a new newsgroup proposal. To summarize what you need to do, just send an empty e-mail to postgresql-ballot@netagw.com You will receive a ballot by e-mail. Follow the...
8
by: William Drew | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.databases.mysql This is an invitation to discuss the following proposal to create newsgroup comp.databases.mysql. Please note that YOU...
14
by: Otis Green | last post by:
Vote for or against a new newsgroup proposal. To summarize what you need to do, just send an empty e-mail to postgresql-ballot@netagw.com You'll receive a ballot by e-mail. Follow the...
1
by: lbbs | last post by:
Newbie, so please don't flame me. I am just starting to learn access. I seem a feature in access a while ago, but don't remember what it was called. I seen project lab example that had, a plus...
0
by: Emil Georgiev | last post by:
Hell I have a Web Custom Control project in ASP.NET. I'm using a subclassing technique to add functionality in HyperLink web server control. I want to create a property "BrowserWindow" of my...
3
by: hazz | last post by:
if i have a table record called Rule 1 with 1. table name 2. table column name 3. operator (>,< =) 4. value (0 to n) 5. score how could I create code to create a rule automatically so...
5
by: eliana82 | last post by:
I have problems calculating score percentages within groups. I have created a boat program in access where the information provided is name, team, boat and score. The first query I've done is...
11
by: Monty Taylor | last post by:
Hey everybody, MySQL has put up a poll on http://dev.mysql.com asking what your primary programming language is. Even if you don't use MySQL - please go stick in a vote for Python. I'm...
4
by: kyle christian | last post by:
I am trying to save the high scores of a game I made. Now Im stumped on trying to search through the file. Should I use a string, array, or one of the STL containers to manipulate the information...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.