Jump to content

rocks

New Members
  • Posts

    3
  • Joined

  • Last visited

rocks's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am using codeigniter to build a business review. I have two table Table biz ------------------------------------------------ id | username | bizname | city_id | created_at ------------------------------------------------ Table review ------------------------------------------------ id | bizid | city_id | username | content | created_at So, when a user reviews a business, that business shows on home page(homepage shows only businesses with reviews) I want to query the last username reviewed a business and username's review next to them. For example: Sunny Bowl (3 reviews) [ Mike ] wrote: Simple, fresh, healthy bi-bim-bap for a very reasonable price. Vive Sol (4 reviews) [ Dave ] wrote: Great green salsa, great margaritas and such yummy food. The Sandwich Spot (1 review) [ Liza ] wrote: Dutch crunch bread is freshly baked, not too doughy. But unfortunately with my query I get Sunny Bowl (3 reviews) [ Mike ] wrote: Simple, fresh, healthy bi-bim-bap for a very reasonable price. Sunny Bowl (3 reviews) [ Steve ] wrote: blah blah blah. Vive Sol (2 reviews) [ Dave ] wrote: Great green salsa, great margaritas and such yummy food. Sunny Bowl (3 reviews) [ Jose ] wrote: blah blah blah. Vive Sol (2 reviews) [ Jon ] wrote: blah blah blah. The Sandwich Spot (1 review) [ Liza ] wrote: Dutch crunch bread is freshly baked, not too doughy. So, as you see the query fetches everything, and it looks ugly. If 10 users review Sunny Bowl, then my homepage becomes a Sunny Bowl page, I don't want that. Here is my query: public function get_city_reviews($city_id,$limit,$offset) { $list = array(); // $this->db->distinct('bizid'); $this->db->from('review'); $this->db->join('biz','biz.id = review.bizid'); $this->db->where('biz.city_id',$city_id); $this->db->order_by('review.created_at','desc'); $this->db->limit($limit,$offset); //$this->db->group_by('bizid'); $query = $this->db->get(); foreach($query->result() as $row) { $list[] = $row; } return $list; } On the model side I have: $data['reviews'] = $this->reviews->get_city_reviews($city->id,10,0); When I use GROUB BY it get exactly what I am looking for but it returns a username who posted (added) the business and I the first review for that business. Lets say Sunny Bowl added by Admin and it was first reviewed by Jose. My expectation is : Sunny Bowl (3 reviews) [ Jose ] wrote: blah blah blah. But instead I getting: Sunny Bowl (3 reviews) [ Admin ] wrote: blah blah blah. I hope someone will give me a clue, Thanks
  2. Hi there, I thinks it would be easier if I just post links a those codes instead of pasting all of them here. I am using this business reviews script, and I am having trouble loading city's neighborhoods. The script demo is here : http://demo.upble.com/ On that demo it works fine, but it's forum is dead (No help ) Anyway, here is the view https://github.com/leungxd/upble/blob/master/application/views/biz/add.php At the bottom, he uses javascript to reload the page, but I really couldn't figure it out. Here is the first part of the bottom code <script type="text/javascript"> var cities = []; <?php foreach($cities as $city):?> cities[<?php echo $city->id ?>] = '<?php echo $city->name?>'; <?php endforeach;?> $(function(){ $('#city_id').change(function(){ city_id=$('#city_id').val(); Utils.loadAction('#district_id','/biz/get_children/'+city_id+'/city'); }); $('#catid_1').change(function(){ catid_1=parseInt($('#catid_1').val()); Utils.loadAction('#subcat','/biz/get_children/'+catid_1+'/category'); }); <?php if(isset($biz['rating']) && $biz['rating']>0):?> var biz_rating=parseInt('<?php $biz['rating']?>'); if(biz_rating>0) { $('#rating').val(biz_rating); $('.star-'+biz_rating).addClass('active-star'); $(".rating-hint").html($(".star-"+biz_rating).attr("title")); } <?php endif;?> }); The rest I think is for a map. Could someone explain to me what's going on. PS: A lot of function calling each other, I don't paste all of them here, but I will if requested These are all files https://github.com/leungxd/upble
  3. I'm trying to develop a business directory like yelp. if a user chooses a state EX; New York, then they could select any category they wanted about NY like Restaurants, Bars, Shopping. And if they wanted to look in Connecticut, all those categories should be about CT listings, and so on. What is the theory about this? Is it developed using sessions? I appreciate any clue you provide, Thanks
×
×
  • 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.