Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2009
    Location
    Portugal/Porto
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Listing Values from Column with a <SELECT>

    Hi all..

    As I said before, iam learning this great programing language!!

    Iam with this small problem. I am trying to get data from a table column to a <select> but i dont' now how to retrieve all the values...

    I've got this...
    ---------------------------------------------------------------------
    <?
    include ("config.php");

    $rSQL = mysql_query("SELECT * FROM categorias");

    while($asData = mysql_fetch_array($rSQL))
    {
    $catDat = $asData[1];
    $catDss = count ("$catDat");
    }
    ?>
    <label for "catg"><? print catsr;?></label><select name="catg" id="catg">
    <option><? echo "$catDat";?></option>
    </select>
    <? mysql_close($con); ?>

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    PHP Code:
    echo "<select name=\"catg\" id=\"catg\">";
    $rSQL mysql_query("SELECT * FROM categorias");
    while(
    $asData mysql_fetch_array($rSQL))
    {
       
    $catDat $asData[1];
       
    $catDss count ("$catDat");

       echo 
    "<option>" $catDat "</option>";
    }
    echo 
    "</select>"

  • Users who have thanked angst for this post:

    macpeace (09-11-2009)

  • #3
    New Coder
    Join Date
    Sep 2009
    Location
    Portugal/Porto
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    so simple...

    ok thanks again angst!

  • #4
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Listing Values from Column with a <SELECT>

    Hi macpeace,

    This may help you,
    <?
    include ("config.php");

    $rSQL = mysql_query("SELECT * FROM categorias");

    while($asData = mysql_fetch_array($rSQL))
    {
    $catDat = $asData[1];
    $catDss = count ("$catDat");
    }
    ?>
    <label for "catg"><? print catsr;?></label><select name="catg" id="catg">
    <option value="<? echo "$catDat";?>"><? echo "$catDat";?></option>
    </select>
    <? mysql_close($con); ?>

    Now you will get the values when submitting the form
    Last edited by JohnDubya; 09-22-2009 at 04:21 PM. Reason: Removed advertisement links


  •  

    Posting Permissions

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