[Solved] How do I insert the value from a checkbox into MySQL in php? [duplicate]

First of all I would change these <form method=”post”> <input type=”hidden” name=”blah” value=”blah”> <input type=”checkbox” name=”cbox[]” value=”1″> <input type=”checkbox” name=”cbox[]” value=”1″> <input type=”checkbox” name=”cbox[]” value=”1″> <input type=”checkbox” name=”cbox[]” value=”1″> <input type=”checkbox” name=”cbox[]” value=”1″> <button type=”submit”>Submit</button> </form> As you wont be able to tell severside which one is checked currently you’ll get something like this if … Read more

[Solved] How do i write a function to insert into database

Instead of putting $i in each of the names, give them array-style names like name=”bill[]” and name=”vendor[]”. Then $_POST[‘bill’] and $_POST[‘vendor’] will be arrays, and you can loop through them: $stmt = $conn->prepare(“INSERT INTO yourTable (bill, vendor, detail, quantity, remark) VALUES (?, ?, ?, ?, ?)”);; $stmt->bind_param(“sssis”, $bill, $vendor, $detail, $quantity, $remark); foreach ($_POST[‘bill’] as … Read more

[Solved] print result from mysql query [closed]

mysql_fetch_row will return the data in the array format. sot get the data you should use the below code: $tweet->post(‘statuses/update’, array(‘status’ => “Trending topics”.implode($message))); solved print result from mysql query [closed]

[Solved] PDO Query throws a fatal error saying bound variables does not match number of tokens [closed]

The error is with this code. You are binding the params to different query object. $addTl = “UPDATE teams SET tlName = :tlName, tlSet = :tlSet WHERE tId = :tId”; $addTlQuery = $dbConnect -> prepare($addTl); $addUserQuery -> bindParam(‘:tId’, $_REQUEST[“team”]); $addUserQuery -> bindParam(‘:tlName’, $lastUid); $addUserQuery -> bindParam(‘:tlSet’, $_REQUEST[“tl”]); echo $lastUid. ” Last ID<br>”; echo $_REQUEST[“tl”]. ” … Read more

[Solved] Combining two queries into one

If the existing queries do what you want/need, UNION will make it pretty simple to combine them, something like; SELECT * FROM ( SELECT is_private 0, <field1>,<field2>,<field3>, … ,(SELECT COUNT(*) FROM votes WHERE message_id = m.message_id AND vote_type=”like”) AS likes, (SELECT COUNT(*) FROM votes WHERE message_id = m.message_id AND vote_type=”dislike”) AS dislikes FROM messages m … Read more

[Solved] MySQL delete request not working [closed]

Try like $bdd->exec(‘DELETE FROM `’ . $_SESSION[‘prenom’] . ‘friendlist` WHERE name=”‘ . mysql_real_escape_string($_POST[‘deletefriend’]) . ‘”‘); or like It will work $bdd->exec(“DELETE FROM “. $_SESSION[‘prenom’] . “friendlist WHERE friendname=””.$_POST[“deletefriend’].”‘”); Delete From table_name …. will be the syntax for that 23 solved MySQL delete request not working [closed]

[Solved] MySQL use select for LEFT JOIN ON

Theoretically you can do this. Writing subquery in join statement will have no effect other than filtering the cartesian product of the two tables just like the where condition. But writing query this way makes no sense as we don’t know the context in which you are using it. The above query can be written … Read more

[Solved] What is the error in my query?

In your query, you specify where (MONTH(abc.email_date)=MONTH(NOW()) AND YEAR(abc.email_date)=YEAR(NOW())) But in the subquery (the one returning 18 results), you have 6 emails with a month that is not december 2014. There’s no way that those emails can be returned by a query that explicitly excludes them. You want those emails as well so you get … Read more

[Solved] SQL Timestamp format in PHP [duplicate]

Try this should help: $datedb = “2018-03-01 11:54:33”; $date = date(‘d-m-Y’, strtotime($datedb)); echo $date; // will print 01-03-2018 And read about date() function of php: http://php.net/manual/en/function.date.php; https://www.w3schools.com/php/func_date_date.asp 0 solved SQL Timestamp format in PHP [duplicate]