I'm working on a php script and have hit a deadlock.
The company that I'm working for has a program where they keep all of their items. They wanted to make those items available online, so I contacted the company that made the program and asked them if there was any way to link it to the site, such as an export. They said that they could create a list of variables for me. So, that's what they did. They created a small addition to the program that basically exports a variable list:
Code: Select all
$item1="3"; //where the item1 variable will store the current amount.
$item2="0";
$item3="4";
$item4="10";
etc.Code: Select all
<?php include 'inventoryDocument.php'; ?>Code: Select all
<?php echo $item1; ?>Well now I'm trying to basically enter it into a database and loop it, populating each page automatically.
Here's the code that I'm working on and I'll tell you where I'm stuck:
Code: Select all
<?php
$dbc = mysqli_connect('localhost', 'username', 'password', 'database_name')
or die('Error connecting to MySQL server.');
$query = "SELECT * FROM table_name";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
while($row = mysqli_fetch_array($result))
{
$name = $row['name'];
$itemNumber = $row['itemNumber'];
$finish = $row['finish'];
$size = $row['size'];
$optionalSize = $row['optionalSize'];
$inStockLocationOne = $row['inStockLocationOne'];
$inStockLocationTwo = $row['inStockLocationTwo'];
$inStockLocationThree = $row['inStockLocationThree'];[/b]
if($inStockLocationOne == '0'){
echo "$name ... $itemNumber ... $finish ... $size $optionalSize ... $inStockCharlotte ... $inStockNewOrleans" . '<br />'; //This is for testing only
}
}
mysqli_close($dbc);
?>Then I was going to call upon the variable in the "if" statement, but basically what I end up doing is saying if($inStockLocationOne == '0') which when translated of course the computer will go in and see that the $inStockLocationOne actually is assigned $item1 so it'll never generate the code.
OK FINALLY, my question is: Is there a way to call a variable that's stored in a database? So that when I type in if($inStockLocationOne == '0'), the computer when running the script will turn it into if($item1 == '0')