New to this forum and relatively new to PHP! Although I have been learning fast, this one has stumped me...
I have written PHP script which queries my database for my selected Model ID, it will then find the model, save the results with json formatting with the file name 'results.json' on my server. (code for this is below).
Trouble is, there are multiple Model ID's in my db and I now need to regularly do this for each ID (seperate json file for each Model ID). I want to have a php script that will query the db and for each model id it finds output the required attributes and save as a json file with the filename *Model ID*.json. I will then set up a CRON job to activate the php script every day or so.
I know the answer sits within For each function but no matter what I have tried i get numerous error points. Please can someone out there help me?
I know I need to make the sql query Select * without the WHERE statement.
Oh and thank you to this forum, its helped me solve numerous other problems and learn a lot along the way
$sql = mysql_query("SELECT * FROM `phndeals` WHERE `Model.ID` = '2296'");
$ID = $_GET["ID"];
$response = array();
$posts = array();
$Mins = $row['Tariff.FreeMins'];
$Texts = $row['Tariff.FreeTxts'];
$Data = $row['Tariff.DataAllowance'];
$PhnCost = $row['Offer.PhoneCost'];
$OverallMonthlyCost = $row['Offer.MonthlyCost'];
$Info = $row['Offer.OfferCashback'];
$link = $row['Offer.Link'];
$length = $row['Tariff.Rental'];
$posts = array('length'=> $length, 'Mins'=> $Mins, 'Texts'=> $Texts, 'Data'=> $Data, 'Info'=> $Info, 'PhnCost'=> $PhnCost, 'OverallMonthlyCost'=> $OverallMonthlyCost, 'link'=> $link);
$response['posts'] = $posts;
$fp = fopen('results.json', 'w');
echo "json file created.";