从基于Array的mysql中提取数据

I have a file file.php and inside my file I am using the code bellow to pull some data from my database and display some information.

My code is

$array = $_GET['theurl']; // My url looks like myfile.php?theurl=1,2,3 (id,s)
$sqlnt4 = "select * from mytable WHERE `id` IN ($array)";
$rsdt4 = mysql_query($sql);
$tc4a = mysql_fetch_assoc($rsdt4);
$mycomma4 = ",";
if ($tc4a['a_youtube'] == "#"){
}else{
    while ($tc4 = mysql_fetch_assoc($rsdt4))
    {
        echo $tc4['a_youtube'];
        echo ",";
    }
}

I expect to echo the infos of the two id's (in array) inside my while function, but it returns the results only from the first.

Any ideas?

I am confusing on $sql :

$sqlnt4 = "select * from mytable WHERE `id` IN ($array)";
$rsdt4 = mysql_query($sql);

Can you take a look after changing below:

$sqlnt4 = "select * from mytable WHERE `id` IN ($array)";
$rsdt4 = mysql_query($sqlnt4);

First that's extremely vulnerable to security issues - I hope this isn't used in production and just for playing around.

I recommend switching to PDO, or at the very least securing your variables.

To put that array into the query, you need to implode it into a list, as such.

$list = implode(',', $array);

You can then use the list in the statement, which will look like 1,2,3.

Edit:

I've just realized your $array value isn't actually an array - have you missed code out or is it badly named?

mysql_fetch_assoc: "Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead." http://pt2.php.net/mysql_fetch_assoc

Try mysql_fetch_rows to return all matching rows into an array.