Jump to content

[SOLVED] Simplify This Query


Simsonite

Recommended Posts

Basically i want to store a number of names for different ranks and then have each of them with a rank of 1 to 8.

 

Then i want a script to take this data from the database and asign each name a variable.

 

However when i try to have a different query for each id it caused the script to take up to much data and crash.

 

I hope this helps

Maybe something like this will work:

$qgroup = "SELECT CONCAT_WS(',',name) FROM ".TBL_USER_GROUPS." WHERE id IN('1','2','3','4','5','6','7','8') GROUP BY id";

 

That should return a data set of 8 rows with a column name that looks like:

name

-------

names,in,group,one,comma,separated

names,in,group,two,comma,separated

 

From there you can use split in PHP to do stuff with it.

 

 

It's hard to tell without you posting your structure and some data via a mysql dump..

 

hmm it is still coming up with the error

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home//////public_html/login/include/usergroup.php on line 23

 

Here is the code if you need any more info just ask

 

<?php

$database['dbserver']="//";
$database['dbuser']="//";
$database['dbname']="//";
$database['dbpass']="//";

$con = mysql_connect($database['dbserver'],$database['dbuser'],$database['dbpass']);

mysql_select_db($database['dbname'], $con);


/*************************Queries*****************************/

$qgroup = "SELECT CONCAT_WS(',',name) FROM ".TBL_USER_GROUPS." WHERE id IN('1','2','3','4','5','6','7','8') GROUP BY id";

/*************************Results*****************************/

$result = mysql_query($qgroup1, $con);

/*************************Variables****************************/

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$array = split(',', "$row");
}

echo $array;

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.