SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am a newbie to mysql and PHP thanks to Kevin. I am trying to use pull-down menus in a form, but when I select something it does not populate to mysql.

    Here is a snippet:

    Sub Category:<select multiple name="subcategory[]">
    <option value="Test">Test
    <option value="Test2">Test 2
    </select>


    I used ENUM for the column type and my submission is still not populating my Sub Category Category.

    Can anyone help me?

    Thanks
    Dylan

    using the forms from the "content management section of php and my

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well the form code you posted looks right. Now let's see the PHP code responsible for accepting that form data and placing it into your MySQL. I'd bet that's where the problem lies.

    ------------------
    -Kevin Yank.
    http://www.SitePoint.com/
    Helping Small Business Grow Online!

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>Originally posted by kyank:
    Well the form code you posted looks right. Now let's see the PHP code responsible for accepting that form data and placing it into your MySQL. I'd bet that's where the problem lies.
    <HR></BLOCKQUOTE>

    Hi Kevin, I was using your PHP code that you furnished....this is what I am using:



    &lt;?php

    if ($submit): // A new business has been listed // using the form below.

    $dbcnx = @mysql_connect("localhost", "removedforsecurity", "removedforsecurity");
    mysql_select_db("removedforsecurity");

    $sql = "INSERT INTO Business SET " .
    "Business_Name='$businessname', " .
    "Category='$category', " .
    "Sub_Category='$subcategory', " .
    "Neighborhood='$neighborhood', " .
    "Business_Description='$businessdescription".
    "Address_1='$address1', " .
    "Address_2='$address2', " .
    "City='$city', " .
    "State='$state', " .
    "Phone_Number='$phonenumber', " .
    "E_Mail='email', " .
    "Web_Site='$website', " .
    "Contact_Name='$contactname', " .
    "Date=CURDATE(),".
    "Expiration_Date='$expirationdate'";
    if (mysql_query($sql)) {
    echo("&lt;P&gt;New Business Listing Added&lt;/P&gt;");
    } else {echo("&lt;P&gt;Error Adding New Business Listing: " .mysql_error() . "&lt;/P&gt;");
    }
    ?&gt;

    &lt;P&gt;&lt;A HREF="&lt;?php echo($PHP_SELF); ?&gt;"&gt;
    Add Another Business Listing&lt;/A&gt;&lt;/P&gt;
    &lt;P&gt;&lt;A HREF="authors.php"&gt;Return to Authors list&lt;/A&gt;&lt;/P&gt;
    &lt;?php else: // Allow The User To Enter A New Business Listing
    ?&gt;
    &lt;FORM ACTION="&lt;?php echo($PHP_SELF); ?&gt;" METHOD=POST&gt;
    &lt;P&gt;Enter Business Information:&lt;BR&gt;
    Business Name:
    &lt;INPUT TYPE=TEXT NAME="businessname" SIZE=50 MAXLENGTH=100&gt;&lt;BR&gt;
    Sub Category:&lt;select multiple name="subcategory[]"&gt;
    &lt;option value="Test"&gt;Test
    &lt;option value="Test2"&gt;Test 2
    &lt;/select&gt;&lt;br&gt;




  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Answered in duplicate thread.

    ------------------
    -Kevin Yank.
    http://www.SitePoint.com/
    Helping Small Business Grow Online!

    [This message has been edited by kyank (edited August 03, 2000).]


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
  •