Jump to content

Help With Comparing Lists...


chris1056

Recommended Posts

Okay, So What I Have Now Is This:

-Form Code, Works FINE:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>Newsletter Readers</title>
        <style type="text/css">
            .off {
                visibility: hidden;
            } .on {
                visibility: visible;
            }
        </style>
        <script type="text/javascript">
            window.onload = function() {
                var timeInterval = 5;
                if (typeof timeInterval === 'undefined' || parseInt(timeInterval) <= 0) {
                    timeInterval = 1
                }
                document.getElementById('timeinfo').innerHTML = "Please Wait " + timeInterval + " More Seconds." ;
                var si = setInterval(function() {
                    if (timeInterval === 0) {
                        clearInterval(si);
                    } else {
                        --timeInterval;
                        if (timeInterval !== 0) {
                            document.getElementById('timeinfo').innerHTML = "Please Wait " + timeInterval + " More Seconds.";
                        } else {
                            document.getElementById('timeinfo').className = 'off'; 
                        }
                    }
                }, 1000);
                setTimeout(function() {
                    document.getElementById('submit').className = 'on';
                }, timeInterval * 1000);
            }
        </script>
    </head>
    <body>
        <div id="timeinfo">
        </div>
        <br/>
        <form name="name" action="process.php" method="post">
		<label>
               Last Name:  
            </label>
            <input type="text" name="lastname" id="lastname" />
            <br/>
            <input type="submit" name="submit" id="submit" value="submit" class="off"/>
        </form>
    </body>
</html>

 

 

-Processing Code (Adds data to MySQL Database)

<?php  
$fname=$_POST['lastname'];
mysql_connect("localhost", "root", "***********") or die(mysql_error()); 
mysql_select_db("newsletter") or die(mysql_error()); 
mysql_query("INSERT INTO `data` VALUES ('$lname')"); 
Print "Your information has been successfully added to the database."; 
?>

 

-What I NEED:

After a number of people have added their names, i will have a list of last names that needed to have been entered by those certain people. if they did not add their name, i need to be able to go to a page and Click "Check" to see if they went to my website and added their name.

 

So summing it up/example:

List of ppl who went to site + entered name:

-Joe

-Craig

-Devin

-Liz

 

List of who was supposed to add their name:

-Joe

-Craig

-Devin

-Liz

-Jordan

-Miles

 

When i go to /check.php

Shows those who didn't go to site.:

-Jordan

-Miles

 

I Hope You Understand.

 

Link to comment
https://forums.phpfreaks.com/topic/154975-help-with-comparing-lists/
Share on other sites

Hi

 

Presuming you can have each list in a table like:-

 

EnteredTable

Id, Name

1,Joe

2,Craig

3,Devin

4,Liz

 

ExpectectedTable

Id, Name

1,Joe

2,Craig

3,Devin

4,Liz

5,Jordan

6,Miles

 

 

Simple way to do it (not that efficient but easy to understand)

 

SELECT *
FROM ExpectectedTable
WHERE Id NOT IN (SELECT Id FROM EnteredTable)

 

Probably better:-

 

SELECT *
FROM ExpectectedTable a
LEFT OUTER JOIN EnteredTable b
ON a.Id = b.Id
WHERE b.Id IS NULL

 

All the best

 

Keith

Archived

This topic is now archived and is closed to further replies.

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