I have a table that queries from a database that is updated frequently, and where

<span id="totalvotes1"></span>

and where

<span id="totalvotes2"></span>

I need to be able to be able to identify those in the line

success: function(data) { $('#totalvotes1').text(data); } });

in my ajax for each corresponding row queried... the way it is set up right now, my ajax will just display the information back into

<span id="totalvotes1"></span>

in the last row queried....

<?php

$sql = mysql_query("SELECT * FROM blogData ORDER BY id DESC");
$sql2=mysql_query("SELECT * FROM messages WHERE mod(mes_id,2) = 0 ORDER BY mes_id DESC");
$sql3=mysql_query("SELECT * FROM messages WHERE mod(mes_id,2) = 1 ORDER BY mes_id DESC");

$count_variable = 0;

while(($row = mysql_fetch_array($sql))AND($row2 = mysql_fetch_array($sql2))AND($row3 = mysql_fetch_array($sql3)) ){
    $id = $row['id'];
    $title = $row['title'];
    $content = $row['content'];
    $category = $row['category'];
    $podcast = $row['podcast'];
    $datetime = $row['datetime'];

    $message1=$row2['msg'];
    $mes_id1=$row2['mes_id'];
    $totalvotes1=$row2['totalvotes'];

    $message2=$row3['msg'];
    $mes_id2=$row3['mes_id'];
    $totalvotes2=$row3['totalvotes'];


?>

<table class="content">
<tr>
<td>


<div id="main">
<div id="left">
<span class='up'><a href="" class="vote" name="up" data-options="key1=<?php echo $mes_id1;?>&key2=<?php echo $mes_id2;?>"><img src="up.png" alt="Down" /></a></span><br />
<span id="totalvotes1"><?php echo $totalvotes1; ?></span><br />
</div>
<div id="message">
<?php echo $message1; ?>
</div>
<div class="clearfix"></div>
</div>
<div id="main">
<div id="right">
<br />
<span id="totalvotes2"><?php echo $totalvotes2; ?></span><br />
<span class='down'><a href="" class="vote" name="down" data-options="key1=<?php echo $mes_id1;?>&key2=<?php echo $mes_id2;?>"><img src="down.png" alt="Down" /></a></span>
</div>
<div id="message">
<?php echo $message2; ?>
</div>
<div class="clearfix"></div>
</div>
</td>
</tr>
</table>

<?php
}
?>

here is my general.js file

$(".vote").click(function()  
{
    var id = $(this).attr("id");
    var name = $(this).attr("name");
    var eData = $(this).attr("data-options");
    var dataString = 'id='+ id + '&' + eData ;
    var parent = $(this); 

    if(name=='up')
    {
        $(this).fadeIn(200).html('');
        $.ajax({
            type: "POST",
            url: "up.php",
            data: dataString,
            cache: false,
            success: function(data) { $('#totalvotes1').text(data); }
    });

}
else
{
    $(this).fadeIn(200).html('');
    $.ajax({
        type: "POST",
        url: "down.php",
        data: dataString,
        cache: false,
        success: function(data) { $('#totalvotes2').text(data); }

    });
}
});
});
});
share|improve this question
thank you in advance to anyone who takes the time to help me out... – Patrick Lawler 8 hours ago
if anyone has links... or examples.... I mean anything would help.... does anybody know if this is even possible or am I just completely screwed...? – Patrick Lawler 8 hours ago
the way to do it would be to encode your result in json -> json_encode() and your receiving js to decode it – ianace 8 hours ago
thank you, I have absolutely no idea how to work with json or how I'd implement that here but i will go research it. thank you – Patrick Lawler 8 hours ago
still looking for help... I don't understand how to implement json here.... – Patrick Lawler 8 hours ago
show 4 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.