Jump to content

benanamen

Members
  • Posts

    2,134
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by benanamen

  1. That is the WORST way to ask for help. You have over 7 thousand posts and don't know how make a proper request for help? WHAT isn't working? What is the error message you get? What is the result? Is the missing brace actually in your code and you didn't post it here?
  2. No need to escape, just use single quotes on the elements.
  3. Where is the data coming from? A database?
  4. I smell an XY problem. OP, where does this array data come from? A database? How about showing the code how you come up with this array.
  5. Add 60 days to date <?php $date = new DateTime('2016-09-01'); $date->add(new DateInterval('P60D')); echo $date->format('Y-m-d'); ?>
  6. NO!, You always select the specific column names you want. DO NOT SELECT * Modify this to use the results of your query <!DOCTYPE html> <html> <head> <title></title> </head> <body> <form action="<?= $_SERVER['SCRIPT_NAME'] ?>" method="post"> <select name="sort_by"> <option value="">Select Option</option> <?php $array = array('id' => 'ID', 'name' => 'Name', 'amt' => 'Amount', 'status_filter' => 'Status'); foreach ($array as $key => $value) { $selected = isset($_POST['sort_by']) && $_POST['sort_by'] == $key ? 'selected' : ''; echo "<option value='$key' $selected>$value</option>\n"; } ?> </select> <input name="submit" type="submit" value="Submit"> </form> </body> </html>
  7. You are not going to get any help until you make a coherent post that includes a question
  8. Email me. See my Profile. Site wont allow you to get PM's yet.
  9. Forget about ajax. Lookup Mysql CRUD tutorials. You need to learn basic form html first.
  10. Yes. The form values will be available in the POST array. e.g $_POST['first_name']
  11. Your query is not valid. More importantly you are using obsolete mysql code that has been completely removed from Php. You need to use PDO. https://phpdelusions.net/pdo
  12. Forget about making a function, just learn how to use PDO. Start with a basic select. * In practice, you will not be using a variable for the table name. This is a really basic example. <?php $hostdb = 'localhost'; $dbname = 'your_DB'; $username = 'root'; $password = ''; $table = 'YOURTABLE'; $pdo = new PDO("mysql:host=$hostdb;dbname=$dbname", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "SELECT * FROM $table"; $stmt = $pdo->prepare($sql); $stmt->execute(); $result = $stmt->fetchAll(); echo '<pre>'; print_r($result); echo '</pre>'; ?>
  13. Yeah, but you might as well start using PDO now. Study the link I posted.
  14. You cannot just throw an i onto mysql_* and expect it to magically be mysqli. Start with a basic Mysqli tutorial or better yet, use PDO. https://phpdelusions.net/pdo
  15. Better yet, why dont you tell us what the real problem is that you are trying to solve rather than your attempt at solving it.
  16. I would think that with a unique index, Mysql already knows there is only going to be one result.
  17. You need to stop grabbing stuff off the net. This code is junk. Your time will be better spent to actually learn how to do what you want.
  18. Your code is obsolete, insecure and has been completely removed from Php. It is also vulnerable to SQL Injection. You need to use PDO. https://phpdelusions.net/pdo
  19. You are missing two closing brackets. They open at lines 11 and 32. Use a proper IDE and you won't have these simple problems.
  20. It's not going to work without the opening and closing PHP brackets
  21. Now that you have it working it would be in your "be a better coder" interests to post your "fixed" code. I suspect that although it may work, it is still wrong. We are happy to review what you came up with.
  22. I wasn't trying to be an ***. Programmer's (me included) can be terse in answering. The PDO tutorial link I gave you is very good. You should be able to grasp it fairly easy. We all had to start somewhere. I was basically trying to keep you from wasting your time and provide you the correct direction.
  23. You should have asked your 13 year old. He would have told you that your code is obsolete and has been completely removed from PHP and that your "code" is full of security vulnerabilities. PDO is not a new language. If you took a second to click on the link I provided you would have seen that. You are never going to be a programmer if you get butt hurt when someone tells you the truth.
  24. So much wrong here. The entire code is junk. Toss it and learn PDO. https://phpdelusions.net/pdo
×
×
  • 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.