Jump to content

Sql Query


[dx]
 Share

Recommended Posts

Hello,I have trouble with one sql query

$poruke_re = mysql_query("SELECT ID_MSG FROM $table_messages WHERE ID_TOPIC='$boardch_subject_id' GROUP BY ID_MSG");while($pod_teme = mysql_fetch_array($poruke_re)) {	echo "<br>" . $pod_teme['ID_MSG'];}

Results for this query are 20, 22, 23, 24.What is my problem. I'm getting result four times. When there was just 20, 22, 23 that was tree times etc.I used br tag and expected to get this:

20222324

But for some reason (I'm asking you why), I'm getting this:

20222324202223242022232420222324

Thanks for any help, I'm gonna get crazy becouse of this.:)

Edited by Haris S
Link to comment
Share on other sites

You mean like this?

		$poruke_re = mysql_query("SELECT ID_MSG FROM $table_messages WHERE ID_TOPIC='$boardch_subject_id' GROUP BY ID_MSG");		while ($pod_teme = mysql_fetch_array($poruke_re)) {			print_r($pod_teme);		}	}

I got this:

Array ( [0] => 20 [ID_MSG] => 20 ) Array ( [0] => 22 [ID_MSG] => 22 ) Array ( [0] => 23 [ID_MSG] => 23 ) Array ( [0] => 24 [ID_MSG] => 24 )Array ( [0] => 20 [ID_MSG] => 20 ) Array ( [0] => 22 [ID_MSG] => 22 ) Array ( [0] => 23 [ID_MSG] => 23 ) Array ( [0] => 24 [ID_MSG] => 24 )Array ( [0] => 20 [ID_MSG] => 20 ) Array ( [0] => 22 [ID_MSG] => 22 ) Array ( [0] => 23 [ID_MSG] => 23 ) Array ( [0] => 24 [ID_MSG] => 24 )Array ( [0] => 20 [ID_MSG] => 20 ) Array ( [0] => 22 [ID_MSG] => 22 ) Array ( [0] => 23 [ID_MSG] => 23 ) Array ( [0] => 24 [ID_MSG] => 24 )

Edited by Haris S
Link to comment
Share on other sites

uhmmm, no i mean like:$poruke_re = mysql_query("SELECT ID_MSG FROM $table_messages WHERE ID_TOPIC='$boardch_subject_id' GROUP BY ID_MSG");$pod_teme = mysql_fetch_array($poruke_re);print_r($pod_teme);

Link to comment
Share on other sites

Now just:

Array ( [0] => 20 [ID_MSG] => 20 )Array ( [0] => 20 [ID_MSG] => 20 )Array ( [0] => 20 [ID_MSG] => 20 )Array ( [0] => 20 [ID_MSG] => 20 )

EDIT:Hi,It was my mistake. I had if statement {}while {}But it must be like if {while {}}That was an error :) Now my problem is solved. Thanks and sorry :)

Edited by Haris S
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...