Jump to content

If Scenario Variable


e1seix

Recommended Posts

I have a slight problem. Using datafeeds in my website, I'm finding that one of my datafeed properites - the identifier - is a series of 6 different numbers eg. 001234. When in fact the number is as so with two zeros at the start my database automatically reverts it to just "1234" which then won't read when i use the identifier in my code to look for changes to product info etc.

 

What simple way is there to say that if a database result is only 4 digits, stick two 0's at the start, and if it's five digits, one zero etc. so i can then redefine variable for use in searching database?

 

any help is always appreciated

 

:)

Link to comment
https://forums.phpfreaks.com/topic/104252-if-scenario-variable/
Share on other sites

I have tried the following code, but it doesn't appear to be working. any tips?

 

// FRAGRANCEDIRECT

$qry9 = mysql_query("UPDATE admin SET inStock='no' WHERE dataID='9'") or die(mysql_error());

$xml = simplexml_load_file('http://datafeeds.productserve.com/datafeed_products.php?user=******&password=******&mid=9&format=xml&dtd=1.2');
foreach ($xml->xpath('//prod') as $character)
{
  $pId9 = $character->pId;
  $awLink9 = $character->awLink;
  $promo9 = $character->promo;
  $search9 = $character->price->search;

  $pId9 = str_pad($pId9, 6, "0", STR_PAD_LEFT);

$result9 = mysql_query("UPDATE admin SET inStock='yes',dataDesc='$desc9',dataP='$search9',dataID='9',dataName='Fragrancedirect',dataWeb='www.fragrancedirect.co.uk',webLink='http://www.awin1.com/awclick.php?mid=9&id=74040',dataLink='$awLink9' WHERE dataID='9' AND dataCode='$pId9'") or die(mysql_error());
}

Link to comment
https://forums.phpfreaks.com/topic/104252-if-scenario-variable/#findComment-533765
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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