-
Posts
2,134 -
Joined
-
Last visited
-
Days Won
42
Everything posted by benanamen
-
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?
-
No need to escape, just use single quotes on the elements.
-
Where is the data coming from? A database?
-
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.
-
Add 60 days to date <?php $date = new DateTime('2016-09-01'); $date->add(new DateInterval('P60D')); echo $date->format('Y-m-d'); ?>
-
Help with php to display a list from a SQL Query
benanamen replied to ricmcdonald's topic in PHP Coding Help
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> -
You are not going to get any help until you make a coherent post that includes a question
-
Run SQL Query via button click on user input
benanamen replied to Jawanaut's topic in PHP Coding Help
Email me. See my Profile. Site wont allow you to get PM's yet. -
Run SQL Query via button click on user input
benanamen replied to Jawanaut's topic in PHP Coding Help
Forget about ajax. Lookup Mysql CRUD tutorials. You need to learn basic form html first. -
Run SQL Query via button click on user input
benanamen replied to Jawanaut's topic in PHP Coding Help
Yes. The form values will be available in the POST array. e.g $_POST['first_name'] -
Run SQL Query via button click on user input
benanamen replied to Jawanaut's topic in PHP Coding Help
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 -
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>'; ?>
-
Yeah, but you might as well start using PDO now. Study the link I posted.
-
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
-
Concat multidimensional array with normal array
benanamen replied to luiggicc's topic in PHP Coding Help
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. -
I would think that with a unique index, Mysql already knows there is only going to be one result.
-
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.
-
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
-
It's not going to work without the opening and closing PHP brackets
-
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.
-
PHP working differently in different browsers
benanamen replied to trenttdogg's topic in PHP Coding Help
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. -
PHP working differently in different browsers
benanamen replied to trenttdogg's topic in PHP Coding Help
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. -
PHP working differently in different browsers
benanamen replied to trenttdogg's topic in PHP Coding Help
So much wrong here. The entire code is junk. Toss it and learn PDO. https://phpdelusions.net/pdo