Jump to content

[SOLVED] Use data from database as variables


Kairu

Recommended Posts

Alright. I hate to be asking so many questions. Hopefully sometime so I can help answer them.

I was wondering if it is possible to take the data that "$row = mysql_fetch_row($result);" creates, and make some of the data variables.

Lets say $row[0] is the identifyer, $row[1] is an image, $row[2] is another image, and $row[3] & $row[4] are the x and y coordinates I want the second image to be written onto the first.

I was wondering if it's possible for the database data to be "$size[0] - $avi_width[8] - 5" for $row[3], and have it indentify that $size[0] and $avi_width[8] are variables and not part of the string?

Any help is once again appreciated and feel free to ask for me to clarify, as I'm getting a headache re reading what I wrote. I hope it makes sense to you all!

~Kairu~
You would need to decalre the mysql_fetch_Array as the variable $row for this to work tho

ie

$row = mysql_fetch_array($sql_statement);

You can then pick each of the columns from the database as a different variable using the column header

$id = $row['identifier'];
$img1 = $row['image1'];
$img2 = $row['image2'];

And so on.
But would putting it through mysql_fetch_array() Make it understand that within the database cell containing "$size[0] - $avi_width[8] - 5", the two variables are actually variables? Now that I think about it I get what your saying..... Just thought I should double check....
It didnt work....

Alright. In my database, i have a table named data, the first row looks something like this.

ID = "1"
Base = "http://random.com/image.png"
Num = "1"
Avi1 = "http://rancdom2.com/image2.png"
Avi1_X = "$size[0] - $avi_width[8] - 5"
Avi1_Y = "5"

There are more, but they are unused in this particular image.

Basically, I am taking the base image and applying the image in Avi1, with the coordinates. The x coordinate is in Avi1_X, and the Y in Avi1_Y. Avi1_X currently has variables in it, meaning variables that are inside the code. I want to know if there is a way, with PHP, to take the statement in Avi1_X and have it "execute" the statement within the code.

So I want to know if I can have the database cell have "$size[0] - $avi_width[8] - 5" and output with a numerical value, assuming both of teh variables are numerical.
I just tried a few things and can't seem to make anything work..... is there perhaps a function that will execute code given to it in string form? I know of such a function (with a little work) in visual basic... But can't find anything similar in PHP.....

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.