Jump to content

Maihes

New Members
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Maihes

  • Rank
    Newbie
  • Birthday 09/22/1991

Profile Information

  • Gender
    Male
  • Age
    28
  1. Ok, so based on what you said i changed a bit the db and merged product with prices and the file looks like this now: CREATE TABLE `pricelist` ( `Id` int(11) NOT NULL, `Product` varchar(13) DEFAULT NULL, `Price` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `pricelist` (`Id`, `Product`, `Price`) VALUES (1, 'TS', '17'), (2, 'ESS', '200'), (3, 'ASBB', '70'), (4, 'MSBB', '300'), (5, 'KA', '30'), (6, 'CFS', '80'), (7, 'BK', '30'), (8, 'ODP', '300'), (9, 'GTDP', '1000'), (10, 'GSDP', '1500'), (11, 'SLGH', '25'), (12, 'RCB', '10
  2. wow that is a lot of code an i appreciate so much that you took your time to write it and help out,the thing is please check this out: my project <== this is the page with what i'm trying to do, it may give you a bit more insight ... the thing is that my price table has more items than the product one so not sure how is that a solution to integrate the prices into that table.. i thought about it too but since the prices table has more items .. wasn't sure how to proceed so i just made a table for it(ik i could've make the table like: id,product,price .. but well at the time i just did it l
  3. Heyya, i'm a new member and quite new in web development so i may ask lots of questions in the future(some may be even stupid ones), anyway i hope i will learn a lot from you guys.
  4. well the problem is that my prices DB looks like this: ID,prod1,prod2,prod3,etc, 1 ,10 ,20 ,30 ,etc, and is stored in a table , but then my products list which is stored in a different table looks like: ID,Name 1,prod1 2,prod2 3,prod3 etc so it's a bit difficult to make it the way you said(i would have to change my db and parts of the codes i have in the project ... the array that i posted earlier works fine i just need to invert it like you said and look for the key and display the value instead of looking at value and display key
  5. So i have a dropdown with a list of products $prodval is the variable that once i select a product from the list returns the products ID(which is populated from DB) prices are stored in db too but each have an assigned variable as you could see in the array, so im trying to make the array that once i select a product from the list i get a variable which is = to the selected products price because based on the product's price i need to display certain info on the pace once the product is selected so i need the price for some of information there
  6. and how do i do that i mean: while ($testvalue = current($array)) { if ($testvalue == $prodval) { $proprice = key($array); } next($array); } this part ... because i'm kinda noob with arrays coz if i simply just change the other way around its not working since i think $prodval looks in the value and not key
  7. ok sorry about that .. i wrote a new code which is working fine with a small issue <?php $array = array( $TSprice => 1, $ESSprice => 2, $ASBBprice => 3, $MSBBprice => 4, $KAprice => 5, $CFSprice => 6, $BKprice => 7, $ODPprice => 8, $GTDPprice => 9, $GSDPprice => 10, $SLGHprice => 11, $RCBprice => 12, $RCCBprice => 13, $CCBprice => 14, $STORprice => 15, $CPCprice => 16, $PPPCprice => 17, $PPCprice => 18, $APCprice => 19, $MDFCprice => 20, $SDFCprice => 21, $MTDFCprice => 22, $DSFCprice => 23 ); while ($testvalue =
  8. well if i change in_array part to what you gave me i get as result back : 102030 which is obviously not what i need, but thanks for reply anyway .
  9. <?php $val1 = "10"; $val2 = "20"; $val3 = "30"; $prod = "2"; $array1=array("1" => $val1, "2"=> $val2, "3" => $val3); if (in_array($prod,$array1)) { foreach ($array1 as $result) { $bla = $result; echo $bla; } } else { $bla = 0; echo $bla; } ?> ok so i have this kind of array or at least i need something like this but this returns 0 so if i could get help with this i would really appreciate and i hope i posted this in the right place.
×
×
  • 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.