Jump to content

Not Null Query In Mysql And Php Is Not Working.


mehidy

Recommended Posts

Hi Every one

 

Please see below query, its getting all the check box selected row from my table, but i want to get only if col_ld_shade is not null.

 

$details = "SELECT col_fab_bkng_ref, col_color_name, col_shade_percent, col_ld_sub_no, col_ld_sub_date, col_ld_ref, col_ld_shade, col_dying, col_color_rmks FROM tbl_color WHERE tbl_color_id IN ($ints) AND col_ld_shade IS NOT NULL";

 

Kindly advise. Where is the probelm?

Link to comment
Share on other sites

please see below full code

require("connect.php");
if (isset($_POST['tbl_color_id']))
$ints = implode(', ', $_POST['tbl_color_id']);
$message = "";
$message .= " <p>Dear All<br>Please find below the comments for your ref </p>";
$message .="<table>
   <tr>
  <th>Booking ref</th><th>Color</th><th>Shade%</th><th>Lab Sub no</th><th>Lab sub date</th><th>Lab Ref</th><th>Apvd Shade</th><th>Dyeing Fact</th><th>Remarks</th>
   </tr>";

$details4p = "SELECT col_fab_bkng_ref, col_color_name, col_shade_percent, col_ld_sub_no, col_ld_sub_date, col_ld_ref, col_ld_shade, col_dying, col_color_rmks FROM tbl_color WHERE tbl_color_id IN ($ints) AND col_ld_shade IS NOT NULL";
$details_result4p = mysql_query( $details4p)
   or die ( "Couldn't get Products: ".mysql_error() );
while ( $det_row = mysql_fetch_array ( $details_result4p ) )
{
// message
$message .= "
<tr><td> ".$det_row[ 'col_fab_bkng_ref' ]."</td>
   <td> ".$det_row[ 'col_color_name' ]."</td>
   <td> ".$det_row[ 'col_shade_percent' ]."</td>
  <td> ".$det_row[ 'col_ld_sub_no' ]."</td>
  <td> ".$det_row[ 'col_ld_sub_date' ]."</td>
  <td> ".$det_row[ 'col_ld_ref' ]."</td>
  <td> ".$det_row[ 'col_ld_shade' ]."</td>
  <td> ".$det_row[ 'col_color_rmks' ]."</td>
  </tr>";}
$message .="</table>";	
$message .= "<p>This is an auto generated mail, no need to reply.</p><p>Thanking you<br>noreplay@yahoo.com<br>C</p>";
$to  = 'mehidy@yahoo.com' . ', '; // note the comma
//$to .= 'sultan@yahoo.com';
// subject
$subject = "hi";

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: mehidy@yahoo.com>' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

Link to comment
Share on other sites

Are you sure some values are null and not just empty strings?

 

Try

 

SELECT col_fab_bkng_ref, col_color_name, col_shade_percent,
col_ld_sub_no, col_ld_sub_date, col_ld_ref, col_ld_shade,
col_dying, col_color_rmks
FROM tbl_color
WHERE tbl_color_id IN ($ints)
AND col_ld_shade IS NOT NULL
AND col_ld_shade <> '' 

Edited by Barand
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • 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.