★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum5/HTML/002273.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  PHP
  How do I passed values (variables) from one phtml file to another?

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   How do I passed values (variables) from one phtml file to another?
Eowyn
Junior Member
posted August 04, 2000 03:31 AM     Click Here to See the Profile for Eowyn   Click Here to Email Eowyn     Edit/Delete Message Reply w/Quote
Included here is my source code :

First File : Display_Book.phtml

<HTML>

<HEAD>

<TITLE>Book Search Input Screen</TITLE>


<?

$link = mysql_pconnect("db.ubuyibuy.com","it","it") or die("Unable to connect to SQL server");
mysql_select_db("dev",$link) or die("Unable to select database");

?>


</HEAD>


<BODY>


<FORM>


<form name="Get_Choice">

<BODY bgcolor="#87CEFA">

<BR><BR><FONT SIZE="10"><FONT COLOR="#00688B"><strong>Book Search Input Screen</strong></FONT></FONT></H1>

<BR><BR><FONT SIZE="8"><FONT COLOR="#1E90FF"><strong>Enter choice of Search Mode :</strong></FONT></FONT>

<BR><BR><FONT SIZE="6"><FONT COLOR="#1E90FF"><strong>1 For ISBN.</strong></FONT></FONT>

<BR><FONT SIZE="6"><FONT COLOR="#1E90FF"><strong>2 For Title.</strong></FONT></FONT>

<BR><FONT SIZE="6"><FONT COLOR="#1E90FF"><strong>3 For Subject.</strong></FONT></FONT>

<BR><FONT SIZE="6"><FONT COLOR="#1E90FF"><strong>4 For Author.</strong></FONT></FONT>

<BR><FONT SIZE="6"><FONT COLOR="#1E90FF"><strong>5 For Book Store.</strong></FONT></FONT>

<P>

<BR><BR><input type="text" size "3" name="choice">
<BR><BR><input type="submit" value="Click to enter choice">
<form action="/old?u=http%3A%2F%2Fwww.devshed.com%2FTalk%2FForums%2FForum5%2FHTML%2FBook_Results.phtml&y=1999" method="post">

</P>


<BR><FONT SIZE="6"><FONT COLOR="#1E90FF"><strong>Enter Search String : </strong></FONT></FONT>
<BR><input type="text" size="100" name="SS">
<BR><BR><input type="submit" value="Click to enter Search String">
<form action="/old?u=http%3A%2F%2Fwww.devshed.com%2FTalk%2FForums%2FForum5%2FHTML%2FBook_Results.phtml&y=1999" method="post">


<P>

<INPUT type="submit" name="Display_Results" value="View List" onClick="window.open('http://dev.ubuyibuy.com/johnny/book/Book_Results.phtml','Book_Results','width=800,height=800','srollbars=yes','resizable=yes')">

</P>


<P>

<BR><A HREF="mailto:elaine_voon@yahoo.co.uk"><P><FONT SIZE="+2"><FONT COLOR="#228B22">Contact us via e-mail</FONT></FONT></P></A>

</P>

</BODY>

</FORM>


</HTML>


Second file : Book_Results.phtml

<HTML>

<HEAD>
</HEAD>

<BODY>

<FORM>
<BODY bgcolor="#ADD8E6">

<H1><FONT COLOR="#00688B">Results from Book Search</FONT></H1>


<?

$link = mysql_pconnect("db.ubuyibuy.com","it","it") or die("Unable to connect to SQL server");
mysql_select_db("dev",$link) or die("Unable to select database");


switch ($choice)
{
case "1":
$ISBN=$SS;
$SQL_STATEMENT="SELECT DISTINCT a.ISBN,a.Title,a.Subject,a.Author,b.Store_Name,c.Price
FROM Book_details AS a,BStore_details AS b,Book_Store_details AS c".
"WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))".
"AND (a.ISBN='$ISBN') AND (c.ISBN='$ISBN')";

$result=mysql_query($SQL_STATEMENT,$link) or die("Select Failed!");
return $result;
break;


case "2":
$Title=$SS;
$SQL_STATEMENT="SELECT DISTINCT a.ISBN,a.Title,a.Subject,a.Author,b.Store_Name,c.Price
FROM Book_details AS a,BStore_details AS b,Book_Store_details AS c".
"WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))".
"AND $Title=a.Title";

$result=mysql_query($SQL_STATEMENT,$link) or die("Select Failed!");
return $result;
break;


case "3":
$Subject=$SS;
$SQL_STATEMENT="SELECT DISTINCT a.ISBN,a.Title,a.Subject,a.Author,b.Store_Name,c.Price
FROM Book_details AS a,BStore_details AS b,Book_Store_details AS c".
"WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))".
"AND $Subject LIKE '%a'+.Subject+'%'";

$result=mysql_query($SQL_STATEMENT,$link) or die("Select Failed!");
return $result;
break;


case "4":
$Author=$SS;
$SQL_STATEMENT="SELECT DISTINCT a.ISBN,a.Title,a.Subject,a.Author,b.Store_Name,c.Price
FROM Book_details AS a,BStore_details AS b,Book_Store_details AS c".
"WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))".
"AND $Author=a.Author";

$result=mysql_query($SQL_STATEMENT,$link) or die("Select Failed!");
return $result;
break;


case "5":
$Store_Name=$SS;
$SQL_STATEMENT="SELECT DISTINCT a.ISBN,a.Title,a.Subject,a.Author,b.Store_Name,c.Price
FROM Book_details AS a,BStore_details AS b,Book_Store_details AS c".
"WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))".
"AND $Store_Name=b.Store_Name";

$result=mysql_query($SQL_STATEMENT,$link)or die("Select Failed!");
return $result;
break;


default:
echo ("Please pick the option number of your choice to start a new search. Thank you.");
break;

}

if (mysql_query($SQL_STATEMENT))
{
echo("<P>Query Performed.</P>");
}
else
{
echo("<P>Error performing query."."</P>".
mysql_error()."."."</P>");
exit();
}

if (!$result)
{
echo("<P>Error getting result.".
mysql_error() . "</P>");
exit();
}


while ($row = mysql_fetch_array($result))
{

$ISBN = $row[0];

$err = mysql_error();

If ($err)
{
echo $err;
}
else
{
$result = mysql_query("dev", $SQL_STATEMENT, $link);


$ISBND=$row["ISBN"];
$TitleD=$row["Title"];
$SubjectD=$row["Subject"];
$AuthorD=$row["Author"];
$Store_NameD=$row["Store_Name"];
$PriceD=$row["Price"];


echo ("<TABLE>");
echo ("<tr>");
echo ("<td><strong>ISBN</strong></td>");
echo ("<td><strong>Title</strong></td>");
echo ("<td><strong>Subject</strong></td>");
echo ("<td><strong>Author</strong></td>");
echo ("<td><strong>Store Name</strong></td>");
echo ("<td><strong>Price</strong></td>");
echo ("</tr>";


echo ("<tr>");
echo ("<td>$ISBND</td>");
echo ("<td>$TitleD</td>");
echo ("<td>$SubjectD</td>");
echo ("<td>$AuthorD</td>");
echo ("<td>$Store_NameD</td>");
echo ("<td>$PriceD</td>");
echo ("</tr>");
echo("</TABLE>");

}

}

?>


<!-- The following line Closes Results Window -->


<BR><BR><INPUT type="button" value="Close Window" onClick="window.close('http://dev.ubuyibuy.com/johnny/book/Book_Results.phtml')">


<!--

Below is the e-mail link, for testing purposes, I have inserted my e-mail address here,
it can be changed to the correct e-mail address when this project is tested and implemented

-->

<BR><A HREF="mailto:elaine_voon@yahoo.co.uk"><P><FONT SIZE="+2"><FONT COLOR="#228B22">Contact us via e-mail</FONT></FONT></P></A>


</BODY>

</FORM>

</HTML>

Shiju Rajan
Member
posted August 04, 2000 06:06 AM     Click Here to See the Profile for Shiju Rajan   Click Here to Email Shiju Rajan     Edit/Delete Message Reply w/Quote
Eowyn,
Your question is not clear..
what you are trying to do with both the files..

you should re-write the both the scripts.
I noticed a lot of mistakes in your php files.


<<
<HTML>

<HEAD>

<TITLE>Book Search Input Screen</TITLE>


<?

$link = mysql_pconnect("db.ubuyibuy.com","it","it") or die("Unable to connect to SQL server");
mysql_select_db("dev",$link) or die("Unable to select database");

?>


</HEAD>


<BODY>


<FORM>


<form name="Get_Choice">

<BODY bgcolor="#87CEFA">
>>

see here you are using two body tags and two form tags...i don't know why you are using that..

it can be..

<HTML>
<HEAD>
<TITLE>Book Search Input Screen</TITLE>
</HEAD>

<BODY bgcolor="#87CEFA">

<?

$link = mysql_pconnect("db.ubuyibuy.com","it","it") or die("Unable to connect to SQL server");
mysql_select_db("dev",$link) or die("Unable to select database");

?>
<form name="Get_Choice" action="/old?u=http%3A%2F%2Fwww.devshed.com%2FTalk%2FForums%2FForum5%2FHTML%2Fsomepage.phtml&y=1999" method="post">

...........
then write rest of the codes...

Second file : Book_Results.phtml


<<
>>


Again same mistake here..

<HTML>
<HEAD>
</HEAD>

<BODY bgcolor="#ADD8E6">

<FORM action="/old?u=http%3A%2F%2Fwww.devshed.com%2FTalk%2FForums%2FForum5%2FHTML%2Fsome.phtml&y=1999" method="post">

....


Please post a fresh question and explain what exactly you want?


------------------
SR -
webshiju.com

"The fear of the LORD is the beginning of knowledge..."

Eowyn
Junior Member
posted August 04, 2000 12:30 PM     Click Here to See the Profile for Eowyn   Click Here to Email Eowyn     Edit/Delete Message Reply w/Quote
HI! Thanks for trying to help, I'm sorry I wasn't clearer earlier.

I'm trying to retrieve records from a MySQL Database that I created.
Here's the entity list :

Book_details
(#ISBN, Title, Subject, Author)

BStore_details
(#Store_Code, Store_Name, Store_Address, Store_Tel_Num)

Book_Store_details
(#ISBN, #Store_Code, Price)

I'm trying to retrieve the following fields :
#ISBN, Title, Subject, Store_Name and Price.

The user should be able to enter an ISBN, Title, Subject (or keyword), Author or Book_Store and get a list with the 5 fields displayed above.

I'm new to PHP4 and am not quite sure how to do this, but I'm trying my best and I hope I can learn as much as I can because I think PHP is a great language.

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.