Jump to content

Maihes

New Members
  • Posts

    8
  • Joined

  • Last visited

About Maihes

  • Birthday 09/22/1991

Profile Information

  • Gender
    Male
  • Age
    28

Maihes's Achievements

Member

Member (2/5)

0

Reputation

  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'), (13, 'RCCB', '10'), (14, 'CCB', '450'), (15, 'STOR', '500'), (16, 'CPC', '10'), (17, 'PPPC', '10'), (18, 'PPC', '10'), (19, 'APC', '10'), (20, 'MDFC', '10'), (21, 'SDFC', '10'), (22, 'MTDFC', '10'), (23, 'DSFC', '10'), (24, 'SS', '1'), (25, 'MS', '8'), (26, 'SO', '3'), (27, 'EO', '7'); ALTER TABLE `pricelist` ADD PRIMARY KEY (`Id`); ALTER TABLE `pricelist` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28; COMMIT; so than this can be used for both the prices and for the product dropdown as long as the last 4 rows are not used for the dropdown list then a new `bundle` table for the second dropdown which its the same as the `books` one i sent you(just column names are Id,Pid,Bname) and then lastly the `dopdown` table which remains the same.
  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 like that and stuck with it) .. well tbh atm for this project .. im using 4 different tables for that page (1 is for the prices on the left, 2 are for the drop down lists(1 for each) and 1 more which gets me: SS Req.; MS Req.:; SO Req.:; EO Req.:; Craft Cost:.) .. what i meant about the variables for the prices is that they are required anyway for them to be displayed so that's how i got them .. the thing is that i agree with you and not just my table .. i do feel that even my coding feels messy .. i think i have like 10-15 different php files(well not big files but like different functions for different parts of the page) for that one page .. haha Anyway, if you could be so kind as to check THIS out(its a .rar file containing all the files for that page) and let me know how messy it is and help me out fixing it i would really appreciate. (ofc when you have time to check it) any tips .. suggestions are so much appreciated
  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 = current($array)) { if ($testvalue == $prodval) { $proprice = key($array); } next($array); } ?> ok so this works fine the only problem is that if some of the prices are the same then my result won't show up for all prices just for one. for example as you can see the variables for prices .. each correspond to 1 product which this array is giving me once i select a product from the drop down list. but if for example $TSprice = 10 and $ESSprice = 10 .. when i select TS from drop down $proprice gives me the right value (10) but then if i select ESS it doesnt give me any value only if i change the price for ESS so it doesnt match any of the other prices. So i need to make sure that it gives me the price even if other product has the same price
  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.