SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot lemkepf's Avatar
    Join Date
    Feb 2002
    Location
    WI, USA
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dynamically updated order form using mysql

    Hi all!
    I'm hoping someone can help me...

    I want to build a dynamically updated order form. Basically the page has pull down menues for comptuer parts. At the bottom is a box that will calculate the price automatically. As the user changes the options the price will automatically calculate higher or lower. (kinda like gateway.com customize the PC pages, but i dont' want the user to have to hit a calculate button to get an updated price)

    Here is the kicker... I know i could do this in Javascript (but that would require putting the prices in the javascript itself). I'm trying to have the prices drawn from a mysql database? (using php)

    Does anyone have some example script or could point me to a tutorial somewhere? Thanks alot for all the help!!!

    lemkepf

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could always load the information into a javascript array which could then be used to create the javascript menu.

    http://www.devshed.com/Server_Side/P...enu/page1.html

    I couldn't find the exact article I was looking for but this may help you. If you still need help loading PHP infor into javascript PM me. I don't have a chance to logon a lot anymore but I can help
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    SitePoint Zealot lemkepf's Avatar
    Join Date
    Feb 2002
    Location
    WI, USA
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well that's not quite what i was looking for. The pulldown menues would already be created. I want PHP to query my Mysql database and make an array of the prices of the products. Then with that data, somehow insert just the "price" part of the array into the javascript, so that when a user clicks a pull down menu and selects a product, the price will come from the array and calculate at the bottom of the page.

    does that make more sese? as i'm getting into this i'm getting quite confused myself! hehe!
    thanks for all the help!
    lemkepf

  4. #4
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I understand now and I have done something similar. This may not look pretty but it does work well.

    PHP Code:
    function fetch_positions(){
    $acsql="select positionid, accessname from positions p, access a where a.accessid=p.access";
                    
    $acquery=mysql_query($acsql);        
                    
    $num=mysql_num_rows($acquery);
                    for (
    $x=0;$x<$num;$x++)
                    {
                        
    $row=mysql_fetch_array($acquery);
                        echo 
    "position[".$row['positionid']."]='".$row['accessname']."';";
                    } 
    That should give you an idea of what you need. In the actual PHP script. This will produce a javascript array that looks like this.

    position[0]="Mark"
    position[1]="Sean"
    position[2]="bravo"

    It wouldn't be too hard to adapt to what you need. As for the actual code to make it work I have this.

    PHP Code:
    <script language="javascript1.2">
    <!--
    function change_access(value){
        var position=new Array();    
        <?= fetch_options(); ?>            
    }
    //-->
    </script>
    Of course some of that specifically applys to my script and it is setup in oop so it isn't procedural but you should get the idea. As is it won't work without some minor adjustments but that does what you need it to
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  5. #5
    SitePoint Zealot lemkepf's Avatar
    Join Date
    Feb 2002
    Location
    WI, USA
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey, thanks! i'm still kinda new with this all so if you could post a link to the site that uses it, and maybe the source code for it, so i can see how it all fits together! thanks alot!
    lemkepf


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •