It is currently Tue Feb 07, 2012 8:45 am

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Pass a variable between pages
PostPosted: Thu May 20, 2004 6:31 pm 
Offline

Joined: Thu May 20, 2004 6:29 pm
Posts: 12
I'm new to PHP and learning quickly (I guess) :D

Question.....How do I pass a variable from one page to the next?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 7:20 pm 
Offline
Site Admin

Joined: Thu Apr 29, 2004 10:32 pm
Posts: 386
That depends on how you pass from one page to the other.
Are you using a FORM or a link to pass between the pages?

_________________
Sincerely

berber

Visit the Weber Sites Today,
To see where PHP might take you tomorrow.
PHP code examples : http://www.weberdev.com
PHP & MySQL Forums : http://www.weberforums.com/
Learn PHP Playing Trivia http://www.webertrivia.com
Search for PHP Code Examples http://www.php-code-search.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 7:41 pm 
Offline

Joined: Thu May 20, 2004 6:29 pm
Posts: 12
I am currently using a link. Which leads me to my next issue. The page I was using uses frames and I would need to be able to pass that value into the other frame.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 7:45 pm 
Offline
Site Admin

Joined: Thu Apr 29, 2004 10:32 pm
Posts: 386
If you want my advice, try to avoide frames.
They are good in some cases but ususlly very bad for most.

Is the link to the next page constant or dynamic?

you should do something like :

Code:
<A HREF="http://www.mydomain.com/mypage.php?var1=1&var2=3">Next Page</A>


This will navigate to the next page in the current frame.
If you need to navigate to a diffrent frame named "OtherFrameName" try :

Code:
<A HREF="http://www.mydomain.com/mypage.php?var1=1&var2=3" TARGET="OtherFrameName">Next Page</A>


if the links are dynamic you just build them in your PHP code.

_________________
Sincerely

berber

Visit the Weber Sites Today,
To see where PHP might take you tomorrow.
PHP code examples : http://www.weberdev.com
PHP & MySQL Forums : http://www.weberforums.com/
Learn PHP Playing Trivia http://www.webertrivia.com
Search for PHP Code Examples http://www.php-code-search.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 8:14 pm 
Offline

Joined: Thu May 20, 2004 6:29 pm
Posts: 12
thx.....down to just using one page. getting the variable to pass now (on the same page at least). Now if you don't mind. let me throw a monkey wrench into the equasion.

I have to data sources. The first is used to pull the item list. This one is working correctly. The second should be a result set of the value that is placed in the variable from a choice in the first. Then display records accordingly. Not working.

my link is defined like this:

PHPTest5.php?name=<?php echo $ItemList->Value("itemname") ?>

my second data source is defined as this:
$ItemInfo = WrapMySQLDatabaseResults("ItemDB", "select * from iteminfo where itemname = " . pageParameter("name"," -1") . "", "block=1","ItemInfo");

I'm getting an error returned. I'm obviously missing something right?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 9:34 pm 
Offline
Site Admin

Joined: Thu Apr 29, 2004 10:32 pm
Posts: 386
What is the error you are getting?

_________________
Sincerely

berber

Visit the Weber Sites Today,
To see where PHP might take you tomorrow.
PHP code examples : http://www.weberdev.com
PHP & MySQL Forums : http://www.weberforums.com/
Learn PHP Playing Trivia http://www.webertrivia.com
Search for PHP Code Examples http://www.php-code-search.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 9:39 pm 
Offline

Joined: Thu May 20, 2004 6:29 pm
Posts: 12
Fatal error: Call to a member function on a non-object in E:\Birchwood folder\Birchwood\PHPTest5.php on line 128

128 - <?php $ItemInfo->MoveFirst(); ?>
129 - <?php $ItemInfo->Move($ItemInfo->FirstRecordOnPage() - 1); ?>
130 - <?php while (!$ItemInfo->EOF() && !$ItemInfo->EOB()) { ?>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 10:02 pm 
Offline
Site Admin

Joined: Thu Apr 29, 2004 10:32 pm
Posts: 386
I'm not familiar with your DB wrapper, this is something you will need to solve on your own.

how about connecting directly to you DB?

Code:
<?
mysql_connect("localhost","user","pass") or die("Unable to connect to SQL server");
mysql_select_db("MyDB") or dir("Unable to select database");
$result=mysql_query("SELECT FieldName FROM MyTable") or die(mysql_error());
While($row = mysql_fetch_object($result)) {
    Echo $row->FieldName;
}
?>

_________________
Sincerely

berber

Visit the Weber Sites Today,
To see where PHP might take you tomorrow.
PHP code examples : http://www.weberdev.com
PHP & MySQL Forums : http://www.weberforums.com/
Learn PHP Playing Trivia http://www.webertrivia.com
Search for PHP Code Examples http://www.php-code-search.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 10:19 pm 
Offline

Joined: Thu May 20, 2004 6:29 pm
Posts: 12
ummm....not familiar with what you are calling DB wrapper? I'm using Adobe GoLive to lay out my pages and PHP to code. MYSql is the DB. Is there another way I should be doing this? Still learning so any and help is greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 10:21 pm 
Offline
Site Admin

Joined: Thu Apr 29, 2004 10:32 pm
Posts: 386
for starters, you can try to see if using my code works for you to access the DB. once you can query the DB you can get info and update info as you like.

Make sure you change the parameters in my code to fit your system.

_________________
Sincerely

berber

Visit the Weber Sites Today,
To see where PHP might take you tomorrow.
PHP code examples : http://www.weberdev.com
PHP & MySQL Forums : http://www.weberforums.com/
Learn PHP Playing Trivia http://www.webertrivia.com
Search for PHP Code Examples http://www.php-code-search.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to: