-
PHP not give back duplicate columns
Hello,
I'm building a game in flash with php and mysql.
By loadvars I send an array to a php-script.
The php-script should give me back the name in a column as the array is.
example : 1,2,1,2,3 should give me back one,two,one,two,three
But it gives me back: one, two, three (and not the extra one and two).
This is my script:
PHP Code:
<?php include 'DB.php';
$taal = $_POST['taal']; $getallen = $_POST['getallen']; //example: 1,2,1,2,3';
$conn = @mysql_connect($server,$user,$pass); $database = @mysql_select_db($database,$conn);
$array = array($getallen); $ids = implode(",", $array);
echo ($getallen); //gives me back 1,2,1,2,3 (thats ok)
$query = @mysql_query("SELECT getallen FROM test WHERE woordgetallen IN(".$ids.") AND `lang_id` = '1' ORDER BY NULL");
$counter = 0;
print("&getallennaam=");
while($ourData = @mysql_fetch_array($query)){ $name = $ourData["flashgetallen"]; $counter++; print("$name,"); //gives me back just one, two, three instead of one,two,one,two,three } print("&geladen=1"); ?>
Last edited by asjbak; 08-23-2010 at 11:57 AM.
-
Someone?????
-
This code doesn't do much:
PHP Code:
$array = array($getallen);
That's basically the same as this:
PHP Code:
$array = array(); $array[0] = $getallen;
Then when you try imploding $array, you are just turning it back into a string because array has only one element.
Also, when you do SQL like this:
Code:
SELECT getallen FROM test WHERE woordgetallen IN(1,2,1,2,3) AND `lang_id` = '1' ORDER BY NULL
Then you are asking for all records where woordgetallen is either a 1, 2, or 3. If woordgetallen has unique values for each record, you can get at most 3 records.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|