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~
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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....
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.