Jump to content
  • 0

Custom Report Module


hmaddy

Question

     foreach (Capsule::table('tblhosting')->where("domainstatus", "=", "Active") && ("server", "=", "23")  ->get() as $hosting) {
        ?>
    <tr>
      <th scope="row"><?php echo $hosting->userid  . PHP_EOL; ?></th>
      <td><?php echo $hosting->server  . PHP_EOL; ?></td>
      <td><?php echo $hosting->domain .  PHP_EOL; ?></td>
      <td><?php echo $hosting->username . PHP_EOL; ?></td>
      <td><?php echo $hosting->packageid  . PHP_EOL; ?></td>
    </tr>

    <?php
        }

 

Whats the wrong on && Section. if its have only one codition then it will work. i need to check both conditions.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Change

Capsule::table('tblhosting')->where("domainstatus", "=", "Active") && ("server", "=", "23")  ->get()

To

Capsule::table('tblhosting')->where("domainstatus", "Active")->where("server", "23")->get()

Could also use

Capsule::table('tblhosting')->where(["domainstatus" => "Active", "server" => "23"])->get()

 

Link to comment
Share on other sites

  • 0

To fix this problem, you can use the andWhere method to specify multiple conditions in the where clause, like this:


 

foreach (Capsule::table('tblhosting')
            ->where("domainstatus", "=", "Active")
            ->andWhere("server", "=", "23")
            ->get() as $hosting) {
    // your code here
}


Alternatively, you can use the where method multiple times to specify multiple conditions, like this:

 

foreach (Capsule::table('tblhosting')
            ->where("domainstatus", "=", "Active")
            ->where("server", "=", "23")
            ->get() as $hosting) {
    // your code here
}


Either of these approaches should allow you to specify multiple conditions in the where clause of your query.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated