Jump to content

Eiolon

Members
  • Posts

    358
  • Joined

  • Last visited

Posts posted by Eiolon

  1. Please use the CODE tags when posting code.

     

    Now, it looks like you are trying to create a new product, and allow the user to select what size types are available for this product.

     

    The way you are approaching it is fine, but if you want the user to be able to add "extra extra large" without needing you to create a new database field and add it to the PHP, then I'd create the sizes in their own table and use an array.

     

    But continuing with your method, here is what I would do with your checkboxes:

     

          <label>
            <input type="checkbox" name="small" value="1" />
            Small</label>
          
          <label>
            <input type="checkbox" name="medium" value="1" />
            Medium</label>
          
          <label>
            <input type="checkbox" name="large" value="1" />
            Large</label>
          
          <label>
            <input type="checkbox" name="x_large" value="1" />
            Extra Large</label>
    

     

    Now here is what I would do with your table fields:

     

    product_name, price, details, category, date_added, small, medium, large, x_large

     

    For the four size fields, make it a tinyint(1) and set default to '0'.

     

    When you check the size box, the value of the selection now becomes '1' instead of '0'.  Thing of it like a bit check.

     

    So, for your SQL:

     

    $sql = mysql_query("INSERT INTO products (product_name,price,details,category,date_added,small,medium,large,x_large)
       VALUES('$product_name','$price','$details','$category',now()),'$small','$medium','$large,'$x_large'") or die(mysql_error());
    

  2. Technically, yes, you can create a new user account via PHP (look at phpMyAdmin, for example).  However, you still have to know a valid user account with the appropriate permissions to create ANYTHING within MySQL.  How do you know what usernames/passwords are used for every organization?

     

    Create a 1 page PDF showing how to setup a new username and password with a couple of screenshots.

  3. I recently upgraded to the latest MySQL version.  I noticed when I run a query such as SELECT * FROM table it no longers order by the auto_incrementing ID ASC by default.  I have to tell it to do that.  Instead, it orders alphabetically by the next field.  Is there a way I can change the config to order by ASC by default when selecting everything?

  4. I am using a header tag (<H2></H2>) and am wondering how I could play something on the opposite end, but outside of the <H2></H2> tag as depicted below:

     

    css.jpg

     

    My styling:

     

    h2 {
    font-family:Arial, Helvetica, sans-serif;
    font-size:16px;
    font-weight:bold;
    color:#2858A6;
    padding-bottom:5px;
    border-bottom:1px dotted #DDDDDD;
    }
    

     

    Do I need to create a new DIV and tell it an absolute position to go there or is there another way?

  5. All, then use GROUP BY.

     

    When you use distinct, if ANY of the other fields are different for that one memberid, it is considered distinct.

     

    For example, I have two number 1 id's but they have different names.  therefore they are both listed.

     

    mysql> SELECT DISTINCT id, name FROM test;
    +----+-------+
    | id | name  |
    +----+-------+
    |  1 | cat   |
    |  1 | dog   |
    |  2 | bird  |
    |  3 | horse |
    +----+-------+
    

     

    So I use group and here is the outcome:

     

    mysql> SELECT id, name FROM test GROUP BY id;
    +----+-------+
    | id | name  |
    +----+-------+
    |  1 | cat   |
    |  2 | bird  |
    |  3 | horse |
    +----+-------+
    3 rows in set (0.00 sec)

  6. Just echo the ID in your link.

     

    <td><a href="edit_account.php?id=<?php echo $rows['userid'] ?>">Edit Account</a></td>

     

    On your edit page, use $_GET to get the ID you just echo'd and query the specific user with that ID.

  7. I have a install.php file that I created.  It asks for the MySQL user, pass, hostname and database they want to use.  When the script is run, the tables are created and the MySQL info is inserted into a connection table.

     

    Now the tricky part.  On each page that needs to connect to the MySQL database, I have an include, which contains the following:

     

    define ('DB_USER', ' ');
    define ('DB_PASS', ' ');
    define ('DB_HOST', ' ');
    define ('DB_NAME', ' ');
    
    $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASS) OR die ('Cannot connect to MySQL server.');
    mysql_select_db (DB_NAME) OR die ('Cannot connect to database.');
    
    

     

    How do I tell the database connection script what the variables are from the connections table?  :o 

     

    Yeah, I know I can manually put them in there, but the point of the script was to make it so the user does not have to go into the code.

  8. It depends on how you are validating, but what I normally do in this situation, is I create two separate forms.  They are physically on the same page as each other, but I'll keep the name exclusive to FORM 1 with it's own submit button and I will put the rest of the information in FORM 2 with it's own submit button.  You just need to make the presentation obvious to the user that it is two separate forms and that clicking the update button only updates their respective forms.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.