Jump to content

Display Dynamic Text Dependent on Variable


mdemetri2
Go to solution Solved by mdemetri2,

Recommended Posts

Hi

 

I expect this is possible. If I have three recordsets but one table. Is it possible to alter the results displayed in the table dependent on a variable e.g. returned from the person logged in. Or maybe its case of have the three tables but only displaying them when the variable is to x, y or z?

 

So currently, I have one table that displays content, code extract. 

 

<table width="593" border="0" class="TableContent">
              <?php do { ?>
                <tr>
                  <td width="575" class="TableContent2"><a href="R/zzedit.php?id=<?php echo $row_retail['id'];?>&ref=<?php echo $row_retail['property'];?>"><?php echo $row_retail['id']; ?></a><?php echo $row_retail['item']; ?><?php echo $row_retait['route']; ?><?php echo $row_retail['class']; ?></td>
                </tr>
                <?php } while ($row_retail = mysql_fetch_assoc($retail)); ?>
</table>

Would be great for anyone to point me in the right direction on this or provide some assistance. Appreciated. 

 

mdemetri2

 

Link to comment
Share on other sites

 

Is it possible to alter the results displayed in the table dependent on a variable e.g. returned from the person logged in.

 

Absolutely. You can retrieve the result from database and write it down on the HTML markup, only, for instance if the user_ID = 1, or something similar. If you have more than one result you need to use some looping constructs in php.

Link to comment
Share on other sites

Ok, so it is possible as I was thinking. I'm just not clear on how to achieve it at the moment. Easy bit is setting a variable based on a return from the user logged in. 

 

Its then doing an if else scenario on the table to display the corresponding result set or having the three tables visibility altered depending on the variable returned.....the latter requiring java script I believe. 

Link to comment
Share on other sites

 

 

depending on the type of user logged in (identified by a variable brought back once the user is logged in)

What is that?

 

 

 

then a different table is displayed - as the query to populate the table is different for each table. 

What are these tables? Can we see example queries for each table

Link to comment
Share on other sites

Well, the variable would be $usertype = $row_user['type'] , essentially the result of a query based on '$_SESSION[MM_Username]'. Result would be numeric so user type 1,2 or 3

 

Example code for one table in my first post. The other two would be the same, but use different recordset / queries to populate. 

 

Hope this makes sense. 

Edited by mdemetri2
Link to comment
Share on other sites

what you are asking to do is simple conditional logic (if/else or switch) or even just a lookup (key/value) array to get values/content based on the user type.

 

however, you haven't shown what exactly changes for each different type so no one has been able to show you anything. we don't know if a database query just returns different values, or if you produce different amounts of links,...

 

in fact, you might not need to do anything in your php code and everything would just be handled in the database query statement.

Link to comment
Share on other sites

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.