Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with variable

Status
Not open for further replies.

james0816

Programmer
Jan 9, 2003
295
US
Need help filling a variable if you don't mind. Has to be easy but every way I work it...it's not working. I have the following code snippet:

<?php $Test1->MoveFirst(); ?>
<?php $Test1->Move($Test1->FirstRecordOnPage() - 1); ?>
<?php while (!$Test1->EOF() && !$Test1->EOB()) { ?>
<tr height="16">
<td width="100" height="16"><font color="#ff9933"><font size="-1" color="#ff9900"><font size="2"><a href='TestMe.php?name=<?php echo $Test1->Value("name")?>'><?php echo $Test1->Value("name")?>
</a></font></font></font></td>
</tr>
<?php $Test1->MoveNext(); ?>
<?php } ?>

I am trying to set a variable to the name value. Thought it was as easy as <?php $uname=$name ?>. My page doesn't like that. Can someone help a guy out?

thx as always.
 
What is $Test1? Where does the object come from? What does it contain?
 
Code:
echo $Test->Value("name");
There's nothing wrong with that. I just surmise there is nothing in the value. Check out if your datasource contains the data you expect.
 
It does work to some extent. When the page reloads, it displays the proper information. What I am trying to do is create another variable so I will be able to navigate to another link. That's where I'm getting stuck at.
 
Please give some context about that new variable.
I'm not sure if you are aware that while you have the datasource renewed every time you load the page the variable you set on the page are only present while the script executes.
To pass variable between pages you need either send them with a form or set them to a session,
Won't work:
page1: $newvar = $Test1->Value("name");
The go to page 2
page2: $newvar does not exist.
 
exactly....when the page loads, it loads as such:

<a href='TestMe.php?name=<?php echo $Test1->Value("name")?>'>

with name being a value that is getting reloaded, right? or am i way off base?
 
You are appending the parameter "name" to the URL. Thus, it is a GET parameter and can be acces in the page that receives the request by:
Code:
<?php
echo $_GET['name'];
?>
I think I understand now what you mean. This should answer your question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top