I have a topic and topic_comments table. I want to join them both. The join is on topic.id = topic_comments.parent_id. I want to show the topic with latest comment and order by latest comment createdate. And not show duplicate topics. Can anyone help me? So far I have this: This however doesn ‘t show topics without comments. It only returns
Tag: php
“No database selected” when implementing Zebra_pagination with SQL/PHP
Relatively new to PHP and first Stack question, so apologies in advance for any mistakes on my part. I’m trying to implement Zebra Pagination with my SQL database (using latest MAMP) and getting an error of ‘No database selected’. I think the issue lies in how I’m hooking up my connection with Zebra, but not having a ton of luck
Fatal error stating “Call to a member function bind_param() on a non-object”
I’ve gotten a fatal error, which I do not know where went wrong. My Category page, and this is my function script for getCategoryArrCon Answer If you have noticed, when you echo your prepared statement, it will look just like this: That simple space is important also in the middle of c.image and FROM to make the query valid. Or
Laravel – Add custom column in select with Eloquent query buider
this is a simplified use case, only to illustrate what I want to achieve: Considering this query in pure SQL: How can I add the constant active column using query builder ? Here is my Query Builder without the extra column: Answer Simplest would be to use DB::raw
Magento: domain change from old to new domain and hosting troubles
There are troubles when uploading backup of old website domain to new hosting domain. Now I got many errors and it seems it is with the database . Problem is that, that I do not understand how does SQL working . And also it’s looks like that new domain complaining with old domain name. It means I need to change
PHP fails to insert into Mysql (auto increment)
I have made my Mysql Table link this: That problem occurs because i am not able to insert auto_increment into my mysql query. index.php I post to it by a HTML form and it does executes the query but i get no rows in that table. I thnk its because of auto_increment or Unique or Primary. i was told to
Laravel: getting a single value from a MySQL query
I’m trying get a single value from MySQL database using laravel but the problem I’m getting an array . this is my query result in MySQL command line: my laravel function: expected $data value is a string with value= Admin but what i get is : [{“groupName”:”Admin”}] Answer Edit: Sorry i forgot about pluck() as many have commented : Easiest
How to search for for strings/keywords in Access database using PHP?
I’m working on a school assignment and I’ve an Access database which has a memo field that stores lots of text. I wanna know how I can search for specific keywords in that memo field. For instance, …
Calculate price of rental period
I am working on a project for which I need to calculate prices of holiday homes available in a selected rental period. I need some help with building a SQL query that combines the following tables and …
two foreign keys, how to map with laravel eloquent
I have two tables in MySQL, where the first one is called users and the second one is called games. The table structure is as follows. users id (primary) email password real_name games id (Primary)…