#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Petaling Jaya, Selangor, Malaysia
    Posts
    8
    Rep Power
    0
    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="Book_Results.phtml" 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="Book_Results.phtml" 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>
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    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="somepage.phtml" 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="some.phtml" 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..."
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Petaling Jaya, Selangor, Malaysia
    Posts
    8
    Rep Power
    0
    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.

Similar Threads

  1. loading variables from an external file
    By paulc218 in forum Flash Help
    Replies: 9
    Last Post: February 11th, 2004, 10:30 AM
  2. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 08:27 AM
  3. Gif co-ordinates passed as form variables.
    By glog in forum PHP Development
    Replies: 3
    Last Post: February 2nd, 2004, 04:11 PM
  4. send variables from html to external file
    By Alicia in forum Visual Basic Programming
    Replies: 6
    Last Post: February 1st, 2004, 11:12 AM
  5. .SQL file :: Uploading values
    By RuFFy in forum MySQL Help
    Replies: 1
    Last Post: January 28th, 2004, 08:26 AM

IMN logo majestic logo threadwatch logo seochat tools logo