Home > front end >  Select from mysql table through variable Laravel
Select from mysql table through variable Laravel

Time:10-26

Here uniname is the main data

I want to select those uniname with same seller_id.There can be multiple uniname with same seller id. I am getting the seller_id info from html, where seller_id is passed as id. How to call it through controller for printing. The line I used is,

$university = DB::table('universities')->where('seller_id', '$id');
public function manage_seller_profile($id)
{
    $divisions = Division::orderBy('id','asc')->get();
    $districts = District::orderBy('id','asc')->get();
    $seller_profile = Seller_info::find($id);
    $university = DB::table('universities')->where('seller_id', '$id');
    
    return view('Backend.pages.seller.manage_seller_profile', compact('seller_profile', 'districts', 'divisions', 'university'));
}

CodePudding user response:

You need to remove these single quotes, and add the Laravel ORM select and get functions.

Your code will look like this:

    $university = DB::table('universities')->where('seller_id', '=', $id)->select('uniname')->get();

I put the '=' operator to make the code more readable.

  • Related