Jump to content

Recommended Posts

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 script
ie
<?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
Link to comment
https://forums.phpfreaks.com/topic/10608-help-needed-with-script/
Share on other sites

[!--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
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]
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.