dr_overload Posted May 27, 2006 Share Posted May 27, 2006 I'm a newbie and have tried to work out a script but just simply cant manage it. Any chance someone can help me?Basically all I want to do is have a script that compares the values of two mysql fields, if the are the same, print the value of the third field, else print the value of fourth field.I got the it working from without connecting to the database and giving the values in the scriptie<?php$a=2;$b=2;$c=5;$d=0;if ( $a == $b ) { echo "$c";} else { echo "$d";}?>But when i try to replace the values with what is in the database it doesnt work - I guess my script for comparing the mysql field values is not working properly.Any help would be most appreciate.Cheers Quote Link to comment https://forums.phpfreaks.com/topic/10608-help-needed-with-script/ Share on other sites More sharing options...
litebearer Posted May 27, 2006 Share Posted May 27, 2006 Are you limiting your sql query to specific records, or are you checking every record? Quote Link to comment https://forums.phpfreaks.com/topic/10608-help-needed-with-script/#findComment-39558 Share on other sites More sharing options...
dr_overload Posted May 27, 2006 Author Share Posted May 27, 2006 [!--quoteo(post=377678:date=May 27 2006, 06:10 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ May 27 2006, 06:10 PM) [snapback]377678[/snapback][/div][div class=\'quotemain\'][!--quotec--]Are you limiting your sql query to specific records, or are you checking every record?[/quote]I have a login script and it will take the entry from the row of the inputted username Quote Link to comment https://forums.phpfreaks.com/topic/10608-help-needed-with-script/#findComment-39559 Share on other sites More sharing options...
Ferenc Posted May 28, 2006 Share Posted May 28, 2006 just count the rows returned by the query. if the user and password match, you will have a count of one[code]$sql = mysql_query("SELECT * FROM user_table WHERE user_name_table = $posted_username AND password = $posted_password") or die(mysql_error());if(mysql_num_rows($sql) == '1'){ // user was in database}else{ // user was not in database}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10608-help-needed-with-script/#findComment-39635 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.