Jump to content

Eiolon

Members
  • Posts

    358
  • Joined

  • Last visited

Everything 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. Take a look at REPLACE. http://dev.mysql.com/doc/refman/5.0/en/string-functions.html
  3. Is it possible to log a users IP address using a MySQL trigger when they INSERT UPDATE or DELETE? I am currently using a PHP script to log, but was transitioning to triggers.
  4. 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.
  5. Looks like a user permissions issue, not a code issue. I created a user called dbuser with mypassword and granted all privileges. Works fine.
  6. Not exactly sure why it's not working for you. I copied and pasted it and it works fine. Just make sure you put the <?php ?> brackets in.
  7. I had thought about doing that, and auto saving the rest of the form every couple of seconds so the refresh of the form wouldn't delete the contents. I was just trying to make it seemless to the end user. And yes, typically a new addition will be added to the list whenever the form is filled out.
  8. 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?
  9. Agreed. However, I have yet to encounter anything programmed in Java that didn't require me to install Java on the client. That is what I was referring to.
  10. Why not learn both? PHP is a server-side language so if you are looking to for user interface control for apps, learning Java can be just as beneficial.
  11. I'm looking for a tutorial on how to refresh the contents of a select menu in real-time. I have a form for users to add options to the select menu on the fly without leaving the page, but at the moment they have to hit the refresh on the browser for it to appear in the menu.
  12. You need to use a join if you want to select from multiple tables in a single query. Just compare the item ID's from both tables. http://phpweby.com/tutorials/mysql/32 Also, no need to put the item_name column in user_items because it is already in the items table. You can grab the name from the items table when you write your query.
  13. 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: 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?
  14. 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)
  15. Do you mean you are trying to see all records that belong to a particular memberid?
  16. I typically use DATETIME when I just need to log a date or do some minor calculations. Anything complex, I like to leave the calculations out of the SQL statement and let PHP handle it so I'll use timestamp. But that has been rare for me.
  17. Take a look at this tutorial: http://www.w3schools.com/ajax/ajax_database.asp
  18. Without knowing your directory structure, the connection script should be stored in the level above your public_html folder or it's equivalent (wwwroot for IIS).
  19. 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.
  20. 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? 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.
  21. You are telling $username is equal to what is being sent through a form (via POST). You do not have a form in your code...
  22. 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.
  23. Sorry, I should have elaborated. With a web-based form I could easily add the entry then send the e-mail. But I am wanting users to use a mail client such as Outlook to send the e-mail. I can have support@domain.com autorespond to another e-mail address, of course, but I don't know what makes it autorespond to a PHP/MySQL server.
×
×
  • 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.