Jump to content

Implement a Hidden ID Field?


chaseman

Recommended Posts

I have a while loop that fetches data from the database and prints it out organized in a table.

 

Now I want to implement a voting functionality, the problem I'm encountering is, once I've printed out a list of tables one table after other with the while loop I need to figure out a way to tell the query TO WHICH of those tables to ADD or SUBTRACT the vote.

 

I thought of implement a hidden id field into the while loop of contributions, the id field would be fetched from the auto_increment field in the contribution table in the MySQL database.

 

Since the id field is unique there can be no misunderstandings to which table to add the vote.

 

My question how can I do exactly that? How can I add a hidden id field to the while loop with the table WHICH I then can pass along to the voting script.

 

Here's the while loop:

 

while ($row = mysqli_fetch_array($data)) 
{
	echo "<table padding='0' margin='0' class='knuffixTable'>";
	echo "<tr><td width='65px' height='64px' class='avatar_bg' rowspan='2' colpan='2'><img src='$avatar_path' alt='avatar' /></td><td class='knuffix_username'><strong>" . $user_name;
	echo "</strong><br />" . $row['category'] .  " | " . date('M d, Y', strtotime($row['contributed_date'])) . "</td></tr><tr><td>";
	echo "<form action='' method='post'>
			<input type='submit' name='plusVote' value='Y' />
			<input type='submit' name='minusVote' value='N' />
			</form></td><td class='votes'>Y[ - ] | N[ - ]</td></tr>";
	echo "<tr><td class='knuffix_name' colspan='3'><strong>" . htmlentities($row['name']) . "</strong><br /></td></tr>";
	echo "<tr><td colspan='2' class='knuffix_contribution'><pre>" . $row['contribution'] . "</pre><br /></td></tr>";
	echo "</table>";
}

 

If I simply add $row['con_id'] it's obviously going to be echo'd out, what is the right practice to have it hidden?

Link to comment
Share on other sites

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.