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
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

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.