Jump to content


Photo

Show if text variable is = to record


  • Please log in to reply
2 replies to this topic

#1 webbiz

webbiz
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 29 December 2005 - 01:11 PM

I need to show information if a recordset is = to a set MySQL table varchar value. In this case the value is “reg_lev_user_1".

The following code works to show if there is a record:

// code start
<?php if ($totalRows_Recordset_access_level > 0) { // Show if recordset not empty ?>
Test text
<?php } // Show if recordset not empty ?>
// code end

However, when I adapt the above code to the code below it does not work. In fact the box around the ‘test text’ with the heading ‘Show If’ is replaced with a PHP tag (not sure what they are called). I have tried using single, double and no quotation marks around the text variable and I have echoed the variable on the same page to make sure it is correct. Could someone tell me what I’m doing wrong with this code?

// code start
<?php if ($totalRows_Recordset_access_level == "reg_lev_user_1") { // Show if recordset not empty ?>
<p>Test text </p>
<?php } // Show if recordset not empty ?>
// code end


#2 degsy

degsy
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 05 January 2006 - 02:09 PM

$totalRows_Recordset_access_level

You are comparing to the wrong variable.
totalRows is just that. It is the count of rows found.

If you want to check against the value then it would be something like

<?php if ($row_access_level['user_level'] == "reg_lev_user_1") 


#3 webbiz

webbiz
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 January 2006 - 03:04 PM

Hi thanks. I did work it out once I got some sleep.
Thanks again




[!--quoteo(post=333513:date=Jan 6 2006, 12:09 AM:name=degsy)--][div class=\'quotetop\']QUOTE(degsy @ Jan 6 2006, 12:09 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
$totalRows_Recordset_access_level

You are comparing to the wrong variable.
totalRows is just that. It is the count of rows found.

If you want to check against the value then it would be something like

<?php if ($row_access_level['user_level'] == "reg_lev_user_1") 
[/quote]





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users