Jump to content

scottybwoy

Members
  • Posts

    532
  • Joined

  • Last visited

    Never

Posts posted by scottybwoy

  1. Sorry, thought it was a simple question ;)

    			//If product already exists, update the row.
    			if (array_key_exists($modelId, $_SESSION['item_buy'])) {
    				$price = number_format($price, 2, '.', '');
    				$session_qty = $_SESSION['item_buy'][$modelId][1] + $qty;
    				$prod_net = number_format($qty * $price, 2, '.', '');
    				$prod_vat = number_format($prod_net * VAT, 2, '.', '');
    				$prod_gross = number_format($prod_net + $prod_vat, 2, '.', '');
    
    				$_SESSION['item_buy'][$modelId] = array($price, $session_qty, $prod_net, $prod_vat, $prod_gross);
    			} else {
    				$_SESSION['item_buy'][$modelId] = array($price, $qty, $prod_net, $prod_vat, $prod_gross);
    			}
    

  2. I have a number of sql abstraction functions, but this one always displays a notice message, but returns the correct result.  What do I need to iron out?

    function selectRecord($record, $tbl, $col, $val) {
    
    	$sql = "SELECT $record FROM $tbl WHERE $col = ";
    
    	if (is_int($val)) {
    		$sql .= "$val";
    	} else {
    		$sql .= "'" . $val . "'";
    	}
    
    	//echo $sql;
    	$qry = mssql_query($sql);
    	$res = mssql_result($qry, 0, 0) or trigger_error("$sql Failed", E_USER_NOTICE);
    
    	return $res;
    }
    

     

    Thanks.

  3. Ok, I've tried that and it doesn't seem to return anything.  What am I doing wrong?

    	$arr = array($prod_array['purchasing'], $prod_array['technical']);
    	$rand = array_rand($arr, 1);
    	$prod_array['display'] = $rand[0];
    
    	echo $prod_array['display'];
    

     

    [edit]

     

    No worries, sussed it using this :

    	$arr = array($prod_array['purchasing'], $prod_array['technical']);
    	$rand = array_rand($arr, 1);
    	$prod_array['display'] = $arr[$rand];

     

    Is this the best way to go about it?

  4. Hi,

     

    I have two bits of data in an array, and I just want to choose one randomly.  How can this be done?

     

    Basically I get two blurbs of information, but it is two long to display them both so I want to just display one at a time randomly.  I had a look for how to do it in MSSQL but there only seems to be ways of getting a random row, not column.  Thanks.

  5. lol, sorry that last bit was funny.

     

    Anyway, if you don't want to lose performance with an abstraction layer, I started off using MSSQL in my company, developed my own db class.  Since then I've just copied it for MySQL and changed it all to do the MySQL features.  You can do that for any db you like, call the functions the same and you just have a bunch of DB classes to choose from depending on what project you do, simple.

  6. Hi Obsidian,

     

    Sorry I've been doing other stuff, but I have come back to it and found that when I replace the pound sign with what you suggested, it displays the '£' symbol.  Sorry, I'm not to hot on this area and am getting confused as to what parts get encoded when and for where?

     

    Thanks for your help though.

  7. The comment block is fairly standard

    <!-- footer //-->

     

    Although one guy did have the same issue, deleted the comment block and left a blank line, and it still reported an error on that line.

     

    I posted a link to the site, so people can see for themselves what is going on.  Thanks.

  8. I seem to have stumbled upon an issue, that I have been trawling around the web for only to return with more confusion.

     

    I tried running W3C HTML Validator on this e-commerce site I've been working on, and it returned this error :

    Sorry, I am unable to validate this document because on line 284  it contained one or more bytes that I cannot interpret as utf-8  (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication.
    
    The error was: utf8 "\xA3" does not map to Unicode

     

    I had a look at the output and line 284, it is just a comment block, like many others in the same file.  I tried converting the php file to UTF8 encoding but that just cocked up how the file executed (strange).  But I really don't know what the problem is.  All other sites php generated pages can be validated.  My doctype declaration is correct.  Could is be something to do with the server?

     

    I'm really lost, anyone solved this before?

  9. Thanks Wildteen88, I think we are finally getting somewhere.  That produced this :

    stdClass Object
    (
         [scalar] => PCIDS/LP/R
         [stock] => -20
    )

    What I really need is (using examples in above post):

    stdClass Object
    (
         [network_card] => stdClass Object (
                                                            [stock] => 60
                                                         )
    )

    I finally got that by using :

    $modObj = new stdClass();
    $modObj->$modelId->stock = $stockTotal;
    

     

    Thanks everyone that helped me get there.  Cheers again

  10. Ok, lets say the value of $modelId is "network_card" and the value of $file is "models5" and $stockTotal = 60.  I want $models_stockArr to look something like this :

     

    $models_stockArr = array("models5" => Obj["network_card" -> stock : 60])

     

    There will be different models for the files and then different files, so I'm trying to build something like :

     

    $models_stockArr = array("models5" => (Obj["network_card" -> stock : 60],["24port_switch" -> stock : 10]), "models6" => (Obj["firewire_card" -> stock : 35]))

     

    etc.  I hope that clears things up a bit.  Cheers

  11. Thanks samshel,

     

    I tried using your code, but it still only gives the $modelId as a value in the $file array.  Which is what I had before.

     

    It won't be run 1,000,000's of times, only by the amount of products sold in an order, so the maximum is dependant on how many products we have, which at present is ~ 150.

     

    Strangely if I change the name to $obj, and dump the result it is empty, whilst $modelId remains the actual modelId, so therefore, it doesn't seem to be doing anything.  Do I need to have specific settings to use this exec? 

     

    Also I wanted the object name to be the same as the modelId so I changed it a bit.  My code looks like such now, let me know where I've gone wrong ;)

    $modelId = $v['modelId'];
    $stockTotal = $stockArr['stockTotal'];
    $file = "models$cat";
    
    $class = $modelId;
    exec("class $class { var stock = $stockTotal; } $obj = new $strTime();");
    
    $fnames = array($file => $obj);
    array_push($models_stockArr, $fnames);
    

    As I said with your code it just returns $modelId as $modelId not an object, with my ammended one, it is blank.  Thanks

  12. give your page a .php extension and replace <emptyempty> with

    <?php include(date&time.php); ?>

     

    But really you shouldn't use & in your file name and it would be better to have a file that gets all your data for your page at the top, and then just use

    <?=$var?>

    wherever you want your data.

     

    Also as masterAce14 says, you can probably just get away with using the date function if that's what you want.

     

    Good luck

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