Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7870465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:37:46+00:00 2026-06-03T01:37:46+00:00

I have a page that displays the data of a mysql entry, depending on

  • 0

I have a page that displays the data of a mysql entry, depending on the link the user clicked ($pagename).. Im wondering how I can create a very basic rating system, that will consist of a form with drop down options of 1 to 5, and when the user submits this value, it posts the data to the corresponding ID of the entry thats currently on the page.

   <?php
$pagename = $_GET['name'];
$sql = "SELECT * FROM tblCocktail WHERE name = '$pagename' LIMIT 1";
/*$sql = sprintf(%sql, mysql_real_escape_string($pagename));*/
$result = mysql_query($sql);
if(!$result) {
    // error occured
}
$data = mysql_fetch_assoc($result);
echo "<p class=\"paratitle\">".$data["name"]."&nbsp;&nbsp;&nbsp;&nbsp;</p>";
echo "<p class=\"paratitle3\">".$data["howto"]."&nbsp;&nbsp;&nbsp;&nbsp;</p>";
echo "<p class=\"paratitle2\">".$data["ingredient1"]."&nbsp;&nbsp;&nbsp;&nbsp;</p>";
echo "<p class=\"paratitle3\">".$data["quantity1"]."&nbsp;&nbsp;&nbsp;&nbsp;</p>";
echo "<p class=\"paratitle2\">".$data["ingredient2"]."&nbsp;&nbsp;&nbsp;&nbsp;</p>";
echo "<p class=\"paratitle3\">".$data["quantity2"]."&nbsp;&nbsp;&nbsp;&nbsp;</p>";
echo "<p class=\"paratitle2\">".$data["ingredient3"]."&nbsp;&nbsp;&nbsp;&nbsp;</p>";
echo "<p class=\"paratitle3\">".$data["quantity3"]."&nbsp;&nbsp;&nbsp;&nbsp;</p>";
echo "<p class=\"dateadded\">".$data["dateadded"]."&nbsp;&nbsp;&nbsp;&nbsp;</p>";
?>
                        </div>
                    </div>
                    <div id="cont2">
                        <div id="contentwrap">
                    <form method="POST" action="addrating.php" >
           <input type="hidden" name="cocktailID" value="<?=$data["id"]?>">
           <select id="ratinglevel" name="ratinglevel">
              <option></option>
              <option>1</option>
              <option>2</option>
              <option>3</option>
              <option>4</option>
              <option>5</option>
            </select>
            <input type="submit" value="submit" />
            </form>

addrating.php:

<?php
mysql_select_db("mwheywood", $con);

//insert cocktail details
$sql="INSERT INTO tblRating (cocktailID, value, counter)
VALUES
('$_POST[id]','$_POST[ratinglevel]','1'";

if (!mysql_query($sql,$con))
  {
  die('Error: you fail at life' . mysql_error());
  }
echo "<p>Thanks for voting</p>"

?>

the table I want to save the rating into is linked via “cocktailID” to the data that is being echo’d in the above code.

and the table structure of “tblRating” is: ratingID, cocktailID, value, counter..

I therefore want the option value to save to the corresponding “cocktailID”, in the “value” field, and a “1” posted to the counter field.

-any help is appreciated -matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:37:47+00:00Added an answer on June 3, 2026 at 1:37 am

    Just include the current ID when you send teh form like this

               <form method="POST" action="addrating.php" >
               <input type="hidden" name="cocktailID" value="<?=$data["id"]?>">
               <select id="ratinglevel" name="ratinglevel">
                  <option></option>
                  <option>1</option>
                  <option>2</option>
                  <option>3</option>
                  <option>4</option>
                  <option>5</option>
                </select>
                </form>
    

    This will then return the ID along with the form results at which time you will have the cocktailID available

        if (isset($_POST['cocktailID']) && isset($_POST['ratinglevel']))
            $sql = "INSERT INTO tblRating SET cocktailID = ".mysql_real_escape_string($_POST['cocktailID']).", value = ".mysql_real_escape_string($_POST['ratinglevel']).",counter = 1";
            $result = mysql_query($sql);
            if(!$result) {
                // error occured
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple php page that displays data from a mysql database. I
I have a PHP page that displays MySQL data in a infowindow on a
I have a web page that displays dynamic data which changes every 2 seconds.
i have a page that displays large datasets into html tables. how can i
I am trying to create a page that displays rpg ranks from a mysql
I have a selectmultiple choice widget that gets data from mysql database and displays
I have a site that displays data on travel products from a MySQL database.
So I have a php page that gets data from database and displays a
I have a javascript that fetches data from mysql and displays it in my
I have a page that displays two objects and then the user picks one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.