SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Coventry , UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question php list boxes and mysql

    i have succesfully managed to get my list box to pull the data from the product_name field in the database
    i now need the list box to do exactly the same thing again but pull the price field as well and if possible input it into a variable

    any ideas

    code as it is now posted below
    PHP Code:
    <?php 

     
    // connect to databade
     
    $dbc mysql_connect('********.uk' '********' '********') or die (mysql_error());
     
    mysql_select_db ('mediacentredb'$dbc) or die (mysql_error());

     
     
    ?> 
     <?
     
    //config list box
     
    enhanced_list_box(array(
      
    'table'        => 'products',
      
    'id_field'     => 'product_id',
      
    'value_field'  => 'product_name',
      
    'highlight_id' => 1));
    ?>
     <?
     
    //listbox function
     
    function enhanced_list_box($options){

      
    $sql  "select " $options['id_field'];
      
    $sql .= ", " $options['value_field'];
      
    $sql .= " from " $options['table'];
     
      
      if(isset(
    $options['where_statement'])) {
        
    $sql .= " where " $options['where_statement'] ;
      }
      
      
    //list sorting
      
    $sql .= " order by " $options['value_field'];

      
    $result mysql_query($sql)
                or die(
    "error in SQL");

    echo 
    '<select name="'$options['id_field'], '" size="1">';

    while (
    $row mysql_fetch_array($resultMYSQL_NUM))
    {
      if(
    $row[0] == $options['highlight_id']) {
        echo 
    '<option value="'$row[0], '" SELECTED>',
             
    $row[1], '</option>';
      } else {
        echo 
    '<option value="'$row[0], '">',
             
    $row[1], '</option>';
      }
    }

    echo 
    '</select>';

    ?>
    http://steven-green.co.uk/sqlstuff/sql3.php

    thanks in advance
    Steve
    Last edited by coventryman; Dec 9, 2004 at 08:42.

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Coventry , UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Coventry , UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    btt

  4. #4
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Patience, my friend. Some people were off doing their holiday shopping (or spent part of the evening yesterday listening to Kevin Yank on the radio!).

    Looks like you already have price in your drop down box and using it as a variable. That is what $options['id_field'] is. Or am I totally misunderstanding what you want to do?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Coventry , UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry for the impatience or rather the desire to get this fixed

  6. #6
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by coventryman
    sorry for the impatience or rather the desire to get this fixed
    No problem.

    So is your problem solved or do you still need some help?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web


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
  •