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
https://forums.phpfreaks.com/topic/216036-looping-problem/
Share on other sites

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.