Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-23-2008, 07:20 PM Having a brain fart!
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
I have a database which contains my color definitions for GD2 in the format:

ColorName, Red, Green, Blue

Example:

Red, 255, 0, 0

I am pulling the values from the database and want to assign them via GD2"imagecolorallocate", I just can't seem to get my head around it today so please help if you can... This is the code I have so far.


PHP Code:
 SQL="Select * From Colors";
$ColorValues mysql_query($SQL);
while 
$Values mysql_fetch_array($ColorValues)
{
    
$ColorName $Values["Name"];
    
$Red $Values["Red"];
    
$Green $Values["Green"];
    
$Blue $Values["Blue"];

Sleeping Troll is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-23-2008, 07:33 PM Re: Having a brain fart!
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
your while statement needs to be this:
PHP Code:
while($Values mysql_fetch_array($ColorValues)) 
instead of this:
PHP Code:
while $Values mysql_fetch_array($ColorValues
for one thing

***EDIT***
Did you know that instead of this:
PHP Code:
    $Red $Values["Red"];
    
$Green $Values["Green"];
    
$Blue $Values["Blue"]; 
You may do this?
PHP Code:
      extract($Values); 
This will create variables of the same name as the associate array index names.
__________________
Join me on
Please login or register to view this content. Registration is FREE

Last edited by wayfarer07; 09-23-2008 at 07:37 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Having a brain fart!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11715 seconds with 12 queries