Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/3114-show-if-text-variable-is-to-record/
Share on other sites

$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") 

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) 333513[/snapback][/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") 

 

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.