Jump to content

Archived

This topic is now archived and is closed to further replies.

webbiz

Show if text variable is = to record

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

 

Share this post


Link to post
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") 

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

×

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.