Jump to content

[SOLVED] numrows


timmah1

Recommended Posts

Can somebody tell me why this isn't working?

 

No matter if the data matches or not, it always shoes "You can pick today"

 

<?php
session_start();

require("header.php");
require("config.php");

$user = $_SESSION['SESS_USERNAME'];
$today = date('Y-m-d');
echo "$user<br>";
echo "$today<br>";
		$csql = "SELECT user,picked FROM daily_picks WHERE user = '$user' AND picked = '$today'";
		$cres = mysql_query($csql);
		$numrows = mysql_num_rows($cres);			

			if($numrows == 1){	
				echo "You have already submitted picks for today";
			}
				else {
					echo "You can pick today";
				}
require("footer.php");
?>

 

With the way the database is now, user matches user and picked matches today.

 

Can somebody tell me what's wrong.....

 

Thank you in advance.

Link to comment
https://forums.phpfreaks.com/topic/126638-solved-numrows/
Share on other sites

echoing out numrows gives me 6, so to me, it's obvious that there's a match

 

you code is looking for an EXACT match to the number 1

 

...

if($numrows == 1){	

...

 

try making it look for any number larger than 0

 

...

if($numrows > 0){	

...

 

that should do it

 

 

Link to comment
https://forums.phpfreaks.com/topic/126638-solved-numrows/#findComment-654874
Share on other sites

Works now.

 

Thanks for all your help

<?php
session_start();

require("header.php");
require("config.php");

$user = $_SESSION['SESS_USERNAME'];
$today = date('Y-m-d');
echo "$user<br>";
echo "$today<br>";
		$csql = "SELECT user,picked FROM daily_picks WHERE user = '$user' AND picked = '$today'";
		$cres = mysql_query($csql);
		$numrows = mysql_num_rows($cres);			

			if($numrows > 0){		
				echo "You have already submitted picks for today";
			}
				else {
					echo "You can pick today";
				}
require("footer.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/126638-solved-numrows/#findComment-654882
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.