0

Hi People,

I need to find invalid emails from the database. and display corresponding columns of those emails (name, phone, address etc) with proper pagination.

I have a database with a table named csv_data_table. This table has fields NAME, EMAIL, PHONE, ADDRESS, DESIGNATION.

I have to find invalid emails from the database. I'm using the following code,

$email_array = array(); // define an array to hold all emails

$sql= "select * from csv_data_table";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$email_array[]=$row['EMAIL'];
}

// Now this $email_array has all emails from the table. I'm using foreach to filter out invalid emails.


$invalid_email_arr= array();

foreach($email_array as $value)
{
if(!filter_var($value,FILTER_VALIDATE_EMAIL))
{
$invalid_email_arr[]= $value;

}

}

// $invalid_email_arr is having all invalid emails which I need to display in tabular form... along with its corresponding columns(name, phone, address etc) so.......

$num_invalid_email_arr= count($invalid_email_arr); // count number of array elements.

for($j=0;$j<$num_invalid_email_arr;$j++)
{
$sql_invalid_email_id= "SELECT * FROM csv_data_table WHERE EMAIL='" .$invalid_email_arr[$j]. "'";

$sql_invalid_email_id_rslt= mysql_query($sql_invalid_email_id);

while($sql_invalid_email_id_row=mysql_fetch_array($sql_invalid_email_id_rslt))
{
?>
<tr>
<td>echo $sql_invalid_email_id_row['NAME'];</td>
<td>echo $sql_invalid_email_id_row['EMAIL'];</td>
<td>echo $sql_invalid_email_id_row['PHONE'];</td>
<td>echo $sql_invalid_email_id_row['ADDRESS'];</td>
<td>echo $sql_invalid_email_id_row['DESIGNATION'];</td>
</tr>

echo"<br/><br/>";

<?php 
}


}

That gives me the required data in tabular form. Now issue is the pagination. How do I implement the LIMIT value in such scenario?

2
Contributors
2
Replies
17
Views
3 Years
Discussion Span
Last Post by Albert Pinto
0

Alright, I need not query each email value now... Got this query which detects invalid emails.

$sql_new= "SELECT * FROM csv_data_table WHERE `EMAIL` NOT REGEXP '^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]@[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]\.[a-zA-Z]{2,4}$' LIMIT $start, $limit";

$rslt_new= mysql_query($sql_new);

Thanx.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.