Jump to content

Recommended Posts

I have a table displaying database data and there's a "Dead" button next to each row for users to click when the information in that row is dead. When the button is clicked the info in the row is crossed out. Now this works, but the change isnt permanent. When I refresh the page, the row is no longer crossed out. I think I have to set cookies.. ? but I am unsure on how to do this. Are there any tutorials or something I can watch on this. Just looking at http://php.net/manual/en/function.setcookie.php is not helping. I'm reading it and my brain is like.. what?!?! How do I apply that to what I want to do?

 

Here's my code

php

<?php while($row = $data->fetch_assoc()) { ?>
<tr>

<td><?php echo $row['title']; ?> </td>
<td><?php echo  $row['requester']; ?></td>
<td><?php echo $row['reward']; ?></td>
<td><?php echo $row['qual']; ?></td>
<td><?php echo $row['time']; ?></td>
<td><?php echo $row['category']; ?></td>
<td><a href="<?php $row['link']; ?>"><button class="btn btn-mini btn-primary" type="button">Do This Hit</button></a></td>
<td><button class="btn btn-danger btn-mini dead" type="button">Dead</button></td>

</tr>
<?php } ?>

and here's my javascript

$('table').on('click','.dead',function(){
	
	
          $(this).parent().siblings().css({textDecoration: 'line-through'});
    });
    

I'm just totally stuck right now, so any help is appreciated. Also, if cookies arent the way to go, please feel free to suggest other ways.

 

Thanks.

edit: actually im thinking cookies arent the way to go. That would just change the text for that specific user i think and i dont want that. I want the change to be permanent once someone clicks that button. so now im thinking i should use.... ajax?

$.ajax({
type: "POST",
url: url,
data: data,
success: success,
dataType: dataType
});

How permanent do you want it? If it's permanent permanent I would store it in a database somewhere. If it's just somewhat permanent, since you're already using jQuery, use jQuery.ajax to post to server and store a session variable. Then use that session variable to determine whether it's dead or not when initially loading the page.

I have a table displaying database data and there's a "Dead" button next to each row for users to click when the information in that row is dead. When the button is clicked the info in the row is crossed out. Now this works, but the change isnt permanent. When I refresh the page, the row is no longer crossed out. I think I have to set cookies.. ? but I am unsure on how to do this. Are there any tutorials or something I can watch on this. Just looking at http://php.net/manual/en/function.setcookie.php is not helping. I'm reading it and my brain is like.. what?!?! How do I apply that to what I want to do?

 

Here's my code

php

<?php while($row = $data->fetch_assoc()) { ?>
<tr>

<td><?php echo $row['title']; ?> </td>
<td><?php echo  $row['requester']; ?></td>
<td><?php echo $row['reward']; ?></td>
<td><?php echo $row['qual']; ?></td>
<td><?php echo $row['time']; ?></td>
<td><?php echo $row['category']; ?></td>
<td><a href="<?php $row['link']; ?>"><button class="btn btn-mini btn-primary" type="button">Do This Hit</button></a></td>
<td><button class="btn btn-danger btn-mini dead" type="button">Dead</button></td>

</tr>
<?php } ?>

and here's my javascript

$('table').on('click','.dead',function(){
	
	
          $(this).parent().siblings().css({textDecoration: 'line-through'});
    });
    

I'm just totally stuck right now, so any help is appreciated. Also, if cookies arent the way to go, please feel free to suggest other ways.

 

Thanks.

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.