Kairu Posted December 21, 2006 Share Posted December 21, 2006 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 https://forums.phpfreaks.com/topic/31488-solved-use-data-from-database-as-variables/ Share on other sites More sharing options...
Chronos Posted December 21, 2006 Share Posted December 21, 2006 try mysql_fetch_array instead of rowThen you can call the array vars with their db names.for example, you now call the row identifier with $row[0]. When using mysql_fetch_array you can call it by using $row['id'] Link to comment https://forums.phpfreaks.com/topic/31488-solved-use-data-from-database-as-variables/#findComment-145851 Share on other sites More sharing options...
liam1412 Posted December 21, 2006 Share Posted December 21, 2006 You would need to decalre the mysql_fetch_Array as the variable $row for this to work thoie$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 https://forums.phpfreaks.com/topic/31488-solved-use-data-from-database-as-variables/#findComment-145862 Share on other sites More sharing options...
Kairu Posted December 21, 2006 Author Share Posted December 21, 2006 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 https://forums.phpfreaks.com/topic/31488-solved-use-data-from-database-as-variables/#findComment-145909 Share on other sites More sharing options...
liam1412 Posted December 21, 2006 Share Posted December 21, 2006 Not sure I understand you rlast question but if you think you've got it. if you need any more help give me a shout. Link to comment https://forums.phpfreaks.com/topic/31488-solved-use-data-from-database-as-variables/#findComment-145910 Share on other sites More sharing options...
Kairu Posted December 21, 2006 Author Share Posted December 21, 2006 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 https://forums.phpfreaks.com/topic/31488-solved-use-data-from-database-as-variables/#findComment-145935 Share on other sites More sharing options...
Kairu Posted December 21, 2006 Author Share Posted December 21, 2006 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 https://forums.phpfreaks.com/topic/31488-solved-use-data-from-database-as-variables/#findComment-145955 Share on other sites More sharing options...
HuggieBear Posted December 21, 2006 Share Posted December 21, 2006 I think [url=http://uk.php.net/manual/en/function.eval.php]eval()[/url] is what you're looking for...RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/31488-solved-use-data-from-database-as-variables/#findComment-145958 Share on other sites More sharing options...
Kairu Posted December 22, 2006 Author Share Posted December 22, 2006 Yup! Thanks! Link to comment https://forums.phpfreaks.com/topic/31488-solved-use-data-from-database-as-variables/#findComment-146256 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.