Jump to content

Making PHP check a MySQL value and then acting upon it


Freedom-n-Democrazy

Recommended Posts

I have a table called "newsletters":

+----------------+------+--------+

| email          | mens | womens |

+----------------+------+--------+

| test1@test.com |    0 |      1 |

| test2@test.com |    1 |      1 |

+----------------+------+--------+

 

What I want to do is make it so after PHP unregisters a user, it checks the database to see if they are signed up to any other newsletters, and if they arn't, then to delete the key (email) from the table:

 

Unregistering an e-mail address from the mens newsletter would go something along the lines of this:

$query = "INSERT INTO newsletters(email, mens) VALUES('$email', 0) ON DUPLICATE KEY UPDATE mens = 0";
if (MySQL table newsletters(email == $email + womens == 0) {
$query = "delete from testdb.newsletters where email='$email'";
}

 

This is the line where I need PHP to check, the rest of the code is fine. This line is made up - to give an idea of what I'm trying to do.

if (MySQL table newsletters(email == $email + womens == 0) {

Link to comment
Share on other sites

Don't use w3schools.  The information is quite often out of date (they still list .php3 as a php file extension) or just plain wrong.  If you really want a beginner site like that, I'd recommend Tizag but the first sections of the manual explain the syntax pretty well.

 

As for the list of other things to learn, xhtml is dead.  Use html5, that's where the standard is going.  Also, ajax is javascript.

 

The best way to learn is to practice.  Write a script for any problem you have, whether it's organising your music collection or grabbing the latest tweets.

Link to comment
Share on other sites

html5 is based on canvas for videos and media files <> browser compatibility will take years.(nothing wrong learning html and then xhtml)

 

xhtml is not dead, that stupid, it a extension of html, and html is the back bone of the internet.

 

also

 

You can learn ajax without learning all the aspects of JavaScript, even thu javascript is the backbone of ajax  but you just learn the DOM and basics.

 

w3schools , show you example with a .php3, because the internal workings of the script that is used on w3schools, is configured to see .php3 as normal .php files.

 

There currently running 5.8 php system

 

there no code on w3school that wrong and is cheeked frequently even universities use that web site.

 

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.