Category : sql

I am trying to query categories where product tags is equal to user selected tags in filter bar , Here is the query what I have tried so far : $categories = Category::with(‘products’); // selected tags is array which contain tags if(!empty($selectedTags)) { foreach($categories->get() as $category) { $categories = $category->whereHas(‘products’ , function($query) use($selectedTags) { foreach($selectedTags ..

Read more

I’m not very good with PHP but I’m editing on a code and I received this message: Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘$id’ in ‘where clause’ in C:xampphtdocst3GetDataLeft.php:42 19:46:24.779 -> Stack trace: 19:46:24.779 -> #0 C:xampphtdocst3GetDataLeft.php(42): PDOStatement->execute(Array) 19:46:24.827 -> #1 {main} 19:46:24.860 -> thrown in C:xampphtdocst3GetDataLeft.php on line 42 ..

Read more

I want to submit records in multiple tables via a form, using pdo. In the form there are fields of two tables. Using pdo, how do i send data to both tables in a single form? <?php $nome=$_POST[‘Text1’]; $cognome=$_POST[‘Text2’]; $dataNascita=$_POST[‘Text3’]; $materia=$_POST[‘Text4’]; $voto=$_POST[‘Text5’]; $dataProva=$_POST[‘Text6’]; $pdo = new PDO(‘mysql:host=localhost;dbname=classe;charset=utf8’, ‘root’, ”); $sql = "INSERT INTO studenti (nome, ..

Read more

im trying to practice my php and mysql skills and have a hudge problem, my goal is to create a form that sends the information into the database im stuck at different syntax errors and so on , this code create a Parse error: syntax error, unexpected double-quote mark in C:xampphtdocsinsert.php on line 35 and ..

Read more

this is my html form to add picture in database. <form id="image_form" method="post" enctype="multipart/form-data"> <p><label>Select Image</label> <input type="file" name="image" id="image" /></p><br /> <input type="hidden" name="action" id="action" value="insert" /> <input type="hidden" name="image_id" id="image_id" /> <input type="submit" name="insert" id="insert" value="Insert" class="btn btn-info" /> </form> i am making ajax picture add,edit delete function in ajax.this is the code ..

Read more

I want to use the custom date function format inside my eloquent query to format close_date and close_time concat column. codes: $client_date = client_date(utc_date(), ‘Y-m-d H:i:s’); // THE QUERY $qrs = $this->db ->where("close_date IS NOT NULL") ->where("close_time IS NOT NULL AND CONCAT(close_date, ‘ ‘, close_time) < ‘" . $client_date . "’") ->where(‘status’, 1) ->get(‘product’) ->result(); ..

Read more