hmaddy Posted October 5, 2022 Share Posted October 5, 2022 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. 0 Quote Link to comment Share on other sites More sharing options...
0 leemahoney3 Posted October 5, 2022 Share Posted October 5, 2022 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() 0 Quote Link to comment Share on other sites More sharing options...
0 PUQ Posted December 20, 2022 Share Posted December 20, 2022 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. 0 Quote Link to comment Share on other sites More sharing options...
Question
hmaddy
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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.