PHP forums, MySQL forums, Web Development resources

Home PageHome    PHP ResourcesTopic List    FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups 
 RegisterRegister
    ProfileProfile    Log in to check your private messagesLog in to check your private messages    Download the RSS Reader RSS Feed Download the RSS Reader RSS for this forum Log inLog in 

PHP Forum :: MySQL Forum :: Java Script Forum



Pass a variable between pages
Goto page 1, 2  Next
 
Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General
View previous topic :: View next topic  
Author Message
James0816



Joined: 20 May 2004
Posts: 12

PostPosted: Thu May 20, 2004 5:31 pm    Post subject: Pass a variable between pages Reply with quote

I'm new to PHP and learning quickly (I guess) :D

Question.....How do I pass a variable from one page to the next?
Back to top
View user's profile Send private message
berber
Site Admin


Joined: 29 Apr 2004
Posts: 383

PostPosted: Thu May 20, 2004 6:20 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
James0816



Joined: 20 May 2004
Posts: 12

PostPosted: Thu May 20, 2004 6:41 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
berber
Site Admin


Joined: 29 Apr 2004
Posts: 383

PostPosted: Thu May 20, 2004 6:45 pm    Post subject: Reply with quote

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:1]
<A HREF="http://www.mydomain.com/mypage.php?var1=1&var2=3">Next Page</A>
[/code:1]

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

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

if the links are dynamic you just build them in your PHP code.
Back to top
View user's profile Send private message
James0816



Joined: 20 May 2004
Posts: 12

PostPosted: Thu May 20, 2004 7:14 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
berber
Site Admin


Joined: 29 Apr 2004
Posts: 383

PostPosted: Thu May 20, 2004 8:34 pm    Post subject: Reply with quote

What is the error you are getting?
Back to top
View user's profile Send private message
James0816



Joined: 20 May 2004
Posts: 12

PostPosted: Thu May 20, 2004 8:39 pm    Post subject: Reply with quote

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()) { ?>
Back to top
View user's profile Send private message
berber
Site Admin


Joined: 29 Apr 2004
Posts: 383

PostPosted: Thu May 20, 2004 9:02 pm    Post subject: Reply with quote

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:1]
<?
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;
}
?>
[/code:1]
Back to top
View user's profile Send private message
James0816



Joined: 20 May 2004
Posts: 12

PostPosted: Thu May 20, 2004 9:19 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
berber
Site Admin


Joined: 29 Apr 2004
Posts: 383

PostPosted: Thu May 20, 2004 9:21 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
WeberTrivia Questions WeberTrivia Questions
 Think you are smart? Prove it!. Try your skills with these questions :
 WeberTrivia QuestionsRecursive arrays and multi-dimensional arrays are one and the same. (PHP and MySQL)
 WeberTrivia QuestionsThe \"cache_dir\" tag of the squid configuration has a default of /var/spool/squid. (Linux)

WeberTrivia Questions



PHP Code Examples
 Stream diffrent sizes of images from a single image to save disk space.
 JavaScript dropdown list menu to switch any page.
 Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
 PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside.
 Link Extractor - This function is used to extract links from a given URL. This will convert relative path into absolute path and also remove PHPSESSID stuff.
 Building a Dynamic Form using Javascript and innerHTML. Add form elements in realtime without refreshing the page.
 A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
PHP Forum :: MySQL Forum :: Java Script Forum