Jump to content

Looping problem


unistake

Recommended Posts

Hi all,

 

I am trying to show information on a page if a value collected from a $_GET value is the same as a value in a Mysql database provided that the users email address links the email address next to the value in the mysql database.

 

I have created the script however as there are more than one $row['value'] I can not get a foreach loop to work to scroll through all the $row['value'] values until it finds a matching one.

 

Hope you can see from the code what I am talking about.

 

The code I have is below:

 

<?php
$email = $_SESSION['logname'];
$sql = "SELECT reg FROM sales WHERE email='$email'";
$result = mysqli_query($cxn,$sql)
	or die ("Couldn't execute query");

while($row = mysqli_fetch_assoc($result))
       // NEED HELP INSERTING A FOREACH $ROW['REG'] SEE IF IT MATCHES $_GET['REG'] TYPE OF SCRIPT// 
        {
	if ($row['reg'] == $_GET['reg'] )
		{ 
			echo $row['reg'] . " is registered by you!";	
		}		
	elseif ($row['reg'] != $_GET['reg'] )
		{
			echo $_GET['reg'] . "<br>";
			echo $row['reg'];
			echo $email . "<br>";
			echo "I am sorry but the $_GET[reg] does not seem to be registered by you!";
			exit();
		}
	} 
?>

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.