2016-05-09 5 views
-1

私たちの開発者は最近、私たちのデータベースから最新の投稿を取り出してテーブルに表示するMS SQLクエリと一緒にPHPページを作成することができました。結果に複数回表示されるcss電子メールアドレス(E.Email)を介して強調表示しようとすると助けが必要です。PHP MSSQL複数のメールを強調表示する

// Select queries 
$query = mssql_query(" 

SELECT 
E.EntryID, 
E.FirstName, 
E.MiddleInitial, 
E.LastName, 
E.Address, 
E.City, 
E.Region, 
E.Postalcode, 
E.Country, 
E.DaytimePhone, 
E.EveningPhone, 
E.FaxNumber, 
E.Email, 
E.AuthorizedPerson, 
E.SubmitterType, 
E.Amount, 
E.PaymentMethod, 
E.Company, 
E.CompleteDate, 
CAST (S.Category as TEXT) as SubCat, 
CAST (S.Title as TEXT) as SubmissionTitle, 
CAST (S.CopyrightOwner as TEXT) as SubCopyOwner, 
S.CopyrightYear, 
S.Donate, 
S.FastFrame, 
S.DeclaredValue, 
CAST (S.IntendePurpose as TEXT) as SubPurpose, 
CAST (C.FirstName as TEXT) as Contributors_FirstName, 
CAST (C.LastName as TEXT) as Contributors_LastName, 
CAST (C.Email as TEXT) as Contributors_Email, 
C.IsMember 

FROM 

Entries E LEFT JOIN Submissions S ON E.EntryID = S.EntryID 
LEFT JOIN Contributors C ON C.SubmissionID = S.SubmissionID 
WHERE E.CompleteDate > CONVERT(datetime, '2016-04-10T07:08:22', 126) 
ORDER BY E.CompleteDate DESC 
"); 



// display the results! 
if (!mssql_num_rows($query)) { 
    echo 'No records found'; 
} else { 
    ?> 
    <button id="export" data-export="export">Export</button> 
    <br><br> 
    <table id="ReportTable"> 
     <thead> 
      <tr> 
       <th>EntryID</th> 
       <th>Completed Date</th> 
       <th>First Name</th> 
       <th>Middle Initial</th> 
       <th>Last Name</th> 
       <th>Address</th> 
       <th>City</th> 
       <th>Region</th> 
       <th>Postal Code</th> 
       <th>Country</th> 
       <th>Day Phone</th> 
       <th>Night Phone</th> 
       <th>Fax #</th> 
       <th>Email</th> 
       <th>Authorized Person</th> 
       <th>Submitter Type</th> 
       <th>Amount</th> 
       <th>Pay Method</th> 
       <th>Company</th> 
       <th>Submission Category</th> 
       <th>Submission Title</th> 
       <th>Submission Copyright Owner</th> 
       <th>Submission Copyright Year</th> 
       <th>Vesalius Trust</th> 
       <th>FastFrame Discussion</th> 
       <th>Declared Value</th> 
       <th>Submission Purpose</th> 
       <th>Contributor First Name</th> 
       <th>Contributor Last Name</th> 
       <th>Contributor Email</th> 
       <th>Contributor Is Member</th> 
      </tr> 
     </thead> 
     <tbody> 
     <?php 
      while ($row = mssql_fetch_array($query)) { 
       echo'<tr>'; 
       echo'<td>'. $row['EntryID'].'</td>'; 
       echo'<td>'. $row['CompleteDate'].'</td>'; 
       echo'<td>'. $row['FirstName'].'</td>'; 
       echo'<td>'. $row['MiddleInitial'].'</td>'; 
       echo'<td>'. $row['LastName'].'</td>'; 
       echo'<td>'. $row['Address'].'</td>'; 
       echo'<td>'. $row['City'].'</td>'; 
       echo'<td>'. $row['Region'].'</td>'; 
       echo'<td>'. $row['PostalCode'].'</td>'; 
       echo'<td>'. $row['Country'].'</td>'; 
       echo'<td>'. $row['DayTimePhone'].'</td>'; 
       echo'<td>'. $row['EveningPhone'].'</td>'; 
       echo'<td>'. $row['FaxNumber'].'</td>'; 
       echo'<td>'. $row['Email'].'</td>'; 
       echo'<td>'. $row['AuthorizedPerson'].'</td>'; 
       echo'<td>'. $row['SubmitterType'].'</td>'; 
       echo'<td>'. $row['Amount'].'</td>'; 
       echo'<td>'. $row['PaymentMethod'].'</td>'; 
       echo'<td>'. $row['Company'].'</td>'; 
       echo'<td>'. $row['SubCat'].'</td>'; 
       echo'<td>'. $row['SubmissionTitle'].'</td>'; 
       echo'<td>'. $row['SubCopyOwner'].'</td>'; 
       echo'<td>'. $row['CopyrightYear'].'</td>'; 
       echo'<td>'. $row['Donate'].'</td>'; 
       echo'<td>'. $row['FastFrame'].'</td>'; 
       echo'<td>'. $row['DeclaredValue'].'</td>'; 
       echo'<td>'. $row['SubPurpose'].'</td>'; 
       echo'<td>'. $row['Contributors_FirstName'].'</td>'; 
       echo'<td>'. $row['Contributors_LastName'].'</td>'; 
       echo'<td>'. $row['Contributors_Email'].'</td>'; 
       echo'<td>'. $row['IsMember'].'</td>'; 
       echo'<tr>'; 
      } 
     ?> 
     </tbody> 
    </table> 
+0

だからあなたの開発者は、代わりに別のものを雇うか、誰かが自由のためにここでそれを行いますことを期待しているコードを書こうとの左? – zoubida13

+0

^^^私はOPの元の開発者を見つけたと思います! – WillardSolutions

+0

私はそれをそのようにしましたか? haha – zoubida13

答えて

1

今日、私はとても気分が良いので、今あなたを手伝っています。しかし、StackOverflowはあなたの問題のためにいつも無料のコードを入手できる場所ではありません。 immedatly新しいプログラマーを雇って、この種の仕事を集めてフリーランサーに渡すことをお勧めします。

あなたはこのようなものが必要:

//create a new empty array 
$emailsExists= []; 
while ($row = mssql_fetch_array($query)) { 
    //here comes the cell of tables 
    //... 
    //... 
    //when email comes: 
    echo'<td>'. $row['FaxNumber'].'</td>'; 
    //if this email was already in the array 
    if (in_array($row['Email'], $emailsExists)) { 
     echo'<td><span style="color: red">'. $row['Email'].'</span></td>'; 
    } else { 
     echo'<td>'. $row['Email'].'</td>'; 
     //Put this email into the existsing emails array 
     $emailsExists[] = $row['Email']; 
    } 
    echo'<td>'. $row['AuthorizedPerson'].'</td>'; 
    //... 
    //... 
} //end of while 
+0

私が確かに期待していた以上に、それはうまくいきました。ありがとうございました@lolka_bolka –

関連する問題