How to select the correct id for the specific button pressed in dynamic table
<p>I'm relatively new to jquery and cannot for the life of me get this to return the proper youtube id it just always returns the first one in the table.</p>

<p>php.
I load the youtube id from my database then display it in the table.</p>

<pre><code>require_once 'library/Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
echo '&lt;br/&gt;';
echo '&lt;table width="95%" cellpadding="0" cellspacing="0" align="center" border="0"&gt;'; 

while ($row = mysqli_fetch_assoc($videoquery))
{
$vidid = ($row['id']);
$vidtitle = ($row['title']);
$vidip = ($row['ip']);
$page2 = ($row['page']);
$q = ($row['youtubeid']);

$yt = new Zend_Gdata_YouTube();
$yt-&gt;setMajorProtocolVersion(2);
$videoEntry = $yt-&gt;getVideoEntry($q);
$thumbnail = '&lt;img src="' . $videoEntry-&gt;mediaGroup-&gt;thumbnail[0]-&gt;url . '" width="100" height="92"';

echo '&lt;tr bgcolor="#333"&gt;
 &lt;td width="100px" rowspan="2" nowrap="nowrap" style="border:2px solid #999999"&gt;'.$thumbnail.'&lt;/td&gt;
 &lt;td colspan="2" align="left"&gt;' .$vidtitle. '
 &lt;/td&gt;&lt;/tr&gt;
 &lt;tr bgcolor="#3B3B3B"&gt;&lt;td nowrap="nowrap"&gt;
 &lt;form method="post"&gt;
 &lt;input name="parse" type="hidden" value="playvid" /&gt;&lt;input name="youtubeid" id="youtubeid" type="hidden" value="'.$q.'" /&gt;;
 &lt;input type="button" name="play" id="play" value="Play Video" /&gt;
 &lt;/form&gt;&lt;/td&gt;
 &lt;td align="right"&gt;
 &lt;form method="post" action=""&gt;
 &lt;input type="hidden" name="page2" value="'.$_SERVER['REQUEST_URI'].'"&gt;
 &lt;input name="parse" type="hidden" value="deletepost2" /&gt;
 &lt;input name="postid2" type="hidden" value="'.$vidid.'"/&gt;';
if ($topuserid == $_GET['id']){
 echo '&lt;input type="submit" name="deletepost2" id="deletepost2" value="Delete Video" /';&gt;
}  
echo  '&lt;/form&gt;&lt;/td&gt;&lt;/tr&gt;';  
}  
echo   '&lt;/table&gt;';  
}
</code></pre>

<p>Jquery code</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function(){
$('#play').live('click', function() {
$('#video').empty()
var vidid = $('#youtubeid').val(); 
alert(vidid);
var playvid = '&lt;object width="300" height="193"&gt;'+
'&lt;param name="movie" value="http://www.youtube.com/v/'+vidid+'&amp;amp;hl=en_US&amp;amp;fs=1"&gt;&lt;/param&gt;'+
'&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;'+
'&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;'+
'&lt;embed src="http://www.youtube.com/v/'+vidid+'&amp;amp;hl=en_US&amp;amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="300" height="193"&gt;&lt;/embed&gt;'+
'&lt;/object&gt;';
$('#video').append(playvid);    });
});
&lt;/script&gt;
</code></pre>
