I’m just now getting a small grasp on PHP and mySQL.
I have already written a working program in Javascript, I would like to try to convert all of my Javascript into PHP. All of my Pricing information is currently stored in arrays in Javascript. I plan to store all of my pricing information in mySQL and retrieve it from there.
Is it possible to retrieve from the database and put the contents into an existing variable that does not have the “$”?
This would save me a lot of work going through all of my variables in the HTML part of the code.
example:
current:
<script type=”text/javascript” language=”JavaScript”>
labor_price=new Array()
labor_price[0]=.50 // layout
labor_price[1]=.30 // top track
labor_price[2]=.10 // bottom track
</script>
proposed:
(database)
code, description, price
0 layout .50
1 toptrack .30
2 bottomtrack .10
PHP script:
<?php
// … log in ect …
$result = mysql_query($sql, $conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result)) {
$price = $newArray[‘price’];
labor_price[$code]=$price;
;
}
?>
….
I know this code don’t work, but I’m sure you get the idea what I’m trying to do. Any suggestions or recommendations?