Jump to content

Recommended Posts

Hi Guys,

 

 

I am designing this website that takes votes on images. I need to store the votes for each image against the image name and a username. For this purpose, I need to modify the current code which retrieves votes from the voting system but doesn't have a system to enter the image name dynamically. Below is the code for the same:

 

<?php
ob_start();
$host="localhost";
$username="computat_abhi";
$password="[..]";
$databasename="computat_button";
$tbl_name="record";

$db=mysql_connect ("localhost", "computat_abhi", "[..]")or die(mysql_error());
mysql_select_db($databasename, $db) or die(mysql_error());

if( isset($_POST['Like']) )
{



$sql = 'INSERT INTO record(ImageNumber,LikeCounter) VALUES (\'b1\', 1)';


mysql_query($sql, $db) or die(mysql_error());



echo 'Like vote is registered';
}
elseif(isset($_POST['Dislike']))
{



$sql = 'INSERT INTO record(ImageNumber,DislikeCounter) VALUES (\'b1\', 1)';


mysql_query($sql, $db) or die(mysql_error());

echo 'Dislike vote is registered';
}


ob_end_flush();
?>

<html>
<head>
	<title>

	Do you Like/Dislike this image?

	</title>
</head>
<body>
	<h1>
	Do you Like/Dislike this image?
	</h1>
<form name="form1" method ="post">
	<input type="submit" name="Like"    value="Like">
	<input type="submit" name="Dislike" value="dislike">
</form>
</body>
</html>

 

Another issue is to register a new user on the website www.computationalphotography.in and link it with the voting system above. Looking forward to your help and suggestions.

My exact question is that $sql stores values b1,1 in the column ImageNumber and LikeCounter.Here b1 is the image name which is statically entered into the db. I want this to be dynamically entered for each image name. The code is the part of rating system that I have developed which is referenced again and again when the user votes in a Like/Dislike voting system.

 

if( isset($_POST['Like']) )
{



$sql = 'INSERT INTO record(ImageNumber,LikeCounter) VALUES (\'b1\', 1)';


mysql_query($sql, $db) or die(mysql_error());



echo 'Like vote is registered';
}
elseif(isset($_POST['Dislike']))
{



$sql = 'INSERT INTO record(ImageNumber,DislikeCounter) VALUES (\'b1\', 1)';


mysql_query($sql, $db) or die(mysql_error());

echo 'Dislike vote is registered';
}
[\code]

Thank you for your help.

[quote author=AyKay47 link=topic=354171.msg1672827#msg1672827 date=1329795892]
I hope that isn't your actual db credentials. What exactly do you need help with?
[/quote]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.