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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Aug 2013
    Posts
    149
    Thanks
    21
    Thanked 0 Times in 0 Posts

    Exclamation Calling upon an PHP array INSIDE php

    I have PHP spitting out all the columns of a table so that the end user can edit them. It is also showing every row as well.

    So I want to make it so the 2 fields have a dropdown menu with the possible choices that you can choose when editing these fields so they don't input one that isn't correct.

    So as of right now it just draws upon the very first column from the db and gives only one option on the dropdown.

    How can I make this show all of the values in the for the $row2 andn $row3.

    PHP Code:
    <?php
        
    require_once("connect.php");
        
    $pricesString "SELECT * FROM tbl_prices ORDER BY prices_id";
        
    $pricesQuery mysql_query($pricesString);

    $allManu "SELECT * FROM tbl_manu ORDER BY manu_id DESC LIMIT 30";
        
    $manuResults mysql_query($allManu);
        
    $row2 mysql_fetch_array($manuResults);

    $allType "SELECT * FROM tbl_type ORDER BY type_id DESC LIMIT 30";
        
    $typeResults mysql_query($allType);
        
    $row3 mysql_fetch_array($typeResults);
    ?>
    PHP Code:
    <?php 
    while($row mysql_fetch_array($pricesQuery))
    {
    echo 
    "
    <div class=\"formLines\">
       <form id=\"editForm\" action=\"editItem.php?prices_id="
    .$row['prices_id']."\" method=\"post\">
    <ul>
    <li>
        <label>Type</label><br>
         <select name=\"prices_7\" class=\"small\" id=\"prices_7\">
        <option>--</option>
        <option>"
    .$row3['type']."</option>
        </li>
        <li>
        <label>Item Name</label><br>
        <input name=\"prices_2\" value=\""
    .$row['prices_2']."\" type=\"text\" class=\"small\" size=\"32\"></li>
        <li>
        <label>Menufacturer</label>
         <select name=\"prices_1\" class=\"small\" id=\"prices_1\">
        <option>--</option>
        <option>"
    .$row2['manu_comp']."</option>
        </li>
        <label>Good Condition Price</label><br>
        <input name=\"prices_3\" value=\""
    .$row['prices_3']."\" type=\"text\" class=\"small\" size=\"32\" /></li>
        <li>
        <label>Cracked</label><br>
        <input name=\"prices_4\" value=\""
    .$row['prices_4']."\" type=\"text\" class=\"small\" size=\"32\"></li>
        <li>
        <label>Bad LCD</label><br>
        <input name=\"prices_5\" value=\""
    .$row['prices_5']."\" type=\"text\" class=\"small\" size=\"32\"></li>
        <li>
        <label>Dead</label><br>
        <input name=\"prices_6\" value=\""
    .$row['prices_6']."\" type=\"text\" class=\"small\" size=\"32\"></li>
        
        
        <li class=\"buttonline\"><input type=\"submit\" id=\"Submit2\" value=\"Edit Column\"></li></ul>

        
    </form></div>
    "
    ;
    }
    ?>

  • #2
    Regular Coder
    Join Date
    Aug 2013
    Posts
    149
    Thanks
    21
    Thanked 0 Times in 0 Posts
    Is this doable?

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,038
    Thanks
    23
    Thanked 589 Times in 588 Posts
    I don't think it is the way your doing it. Under <label>Type</label> you have <option>".$row3['type']."</option> This is not going to be what can be placed in that column.

    You either need to make another table with that information or just hand code it like:
    <li>
    <label>Type</label><br>
    <select name=\"prices_7\" class=\"small\" id=\"prices_7\">
    <option>--</option>
    <option>String Beans</option>
    <option>Mushrooms</option>
    <option>Cantalopes</option>
    <option>Tomatoes</option>
    <option>Black Beans</option>
    </li>


    FYI, it's hard to know what is meant by $row3['type'] because we have no idea what your table columns are or what they contain. To me, it's hard to see the connection between a label of "TYPE" and and using a name like prices.
    Evolution - The non-random survival of random variants.

  • #4
    Regular Coder
    Join Date
    Aug 2013
    Posts
    149
    Thanks
    21
    Thanked 0 Times in 0 Posts
    The type is the type of smartphone i.e Smartphone, tablet, laptop, itouch etc. The Prices are the price of the smartphones at different conditions.

    Their is a table that contains all the "types" where the admin can edit, add, delete items so I cannot manually input them as they can be changed. So the $row3 is drawing upon that table taking all the values inside that table (well I want it to, it isnt now) but since it's already inside a <?php tag that draws from another table it cannot draw all rows, just the first one.

  • #5
    Regular Coder
    Join Date
    Aug 2013
    Posts
    149
    Thanks
    21
    Thanked 0 Times in 0 Posts
    Anyone else?

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    I've used the free download from this site:
    http://www.blueicestudios.com/chaine...hp-mysql-ajax/

    See the demo: http://blueicestudios.com/chained-se...es/three-tier/

    You would of course have to customize it to work with your tables/columns.


  •  

    Posting Permissions

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