I have a very simple table holding color info: about a hundred rows, each with 3 columns: colorrID, colorrDescription, colorrValue. I've put all the functions handling mySql queries in a script that I include where necessary. Apparently, 'global' variables declared in 'included' scripts are available in the 'includees', and I don't have to use $_SESSION variables as I thought I would.
The user selects a foreground color and a background color in separate operations. I'd like to use one function to facilitate both selections (and any other changes, later). I thought this would do it:
function getColor($id){
global $re;
$qr = 'SELECT rgb FROM colorr WHERE colorrID = \''.$id.'\';';
$re = mysql_query($qr);
}
It didn't. It returned "Resource id #5" for one and "Resource id #6" for the other, in the order in which they were requested.
So then I tried:
function getColor($id){
global $ra;
$ra = array();
$qr = 'SELECT * FROM colorr;';
$ra = mysql_query($qr) or die(mysql_error());
echo '<pre>'.print_r($ra, 1).'</pre>';
}
I'd hoped to see the entire content of the table. Instead, I saw "Resource #5, Resource #6".
I'm at a loss. If anybody can tell me either what I've done wrong, or what I should do in order to get the colorrValue corresponding to colorrID , I'd be deeply appreciative.
Thanks,
Paul