#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
    Hi, Marty & SR, thanks for your help. However, I tried SR's code and modified it according to what Marty said about not using JS and the submit button just doesn't seem to work.
    Any help will be most appreciated.

    Here are the 2 files again :
    Display_Book.phtml

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

    <BODY bgcolor="#87CEFA">


    <form name="Get_Choice" action="Book_Results.phtml" method="post" target="_blank">
    <div align="center">
    <center>
    <table border="1" width="480" cellspacing="0" cellpadding="0">
    <tr>
    <td width="417" colspan="2">
    <p align="center"><strong><font face="Arial" size="2" color="#00688B">Book Search </font></strong></td>
    </tr>
    <tr>
    <td width="191"><font face="Arial" size="2">Enter choice of Search Mode :</font></td>
    <td width="283"><strong><font color="#1E90FF" face="Arial" size="2"><select size="1" name="choice">
    <option selected value="1">For ISBN</option>
    <option value="2">For Title</option>
    <option value="3">For Subject</option>
    <option value="4">For Author</option>
    <option value="5">For Book Store</option>
    </select></font></strong></td>
    </tr>
    <tr>
    <td width="191"><font face="Arial" size="2">Enter Search String :</font></td>
    <td width="283"><input type="text" size="39" name="SS">


    </td>
    </tr>
    <tr>
    <td width="417" colspan="2">
    <p align="center"><INPUT type="submit" value="Submit" name="action">

    </td>
    </tr>
    </table>
    </center>
    </div>
    <p> </p>

    </form>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>

    <p><A HREF="http://dev.ubuyibuy.com/johnny/book/Book_Results.phtml"><FONT SIZE="3"><FONT COLOR="#228B22">Click here to view results</FONT></FONT></A>

    <p><A HREF="mailto:elaine_voon@yahoo.co.uk"><FONT SIZE="3"><FONT COLOR="#228B22">contact us via e-mail</FONT></FONT></A>

    </p>

    </BODY>


    </HTML>


    And Book_Results.phtml :

    <HTML>
    <HEAD>
    </HEAD>
    <BODY bgcolor="#ADD8E6">

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


    <?

    if(isset($submit)){
    //if user clicks on view list button..


    $con = mysql_connect("db.ubuyibuy.com","it","it");
    //connection string

    mysql_select_db("dev",$con) ;
    //select your database/


    $SQL_STATEMENT="SELECT DISTINCT a.ISBN,a.Title,a.Subject,a.Author,b.Store_Name,c.Price";
    $SQL_STATEMENT.="FROM Book_details AS a,BStore_details AS b,Book_Store_details AS c";


    //create your sql statement as the choice..

    if ($choice=="1")
    {
    $ISBN=$SS;
    $SQL_STATEMENT.="WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))";
    $SQL_STATEMENT.="AND (a.ISBN='$ISBN') AND (c.ISBN='$ISBN')";
    }

    elseif ($choice=="2")

    {
    $Title=$SS;
    $SQL_STATEMENT.="WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))";
    $SQL_STATEMENT.="AND $Title=a.Title";
    }

    elseif ($choice=="3")

    {
    $Subject=$SS;
    $SQL_STATEMENT.="WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))";
    $SQL_STATEMENT.="AND $Subject LIKE '%a'+.Subject+'%'";
    }

    elseif ($choice=="4")
    {
    $Author=$SS;
    $SQL_STATEMENT.="WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))";
    $SQL_STATEMENT.="AND $Author=a.Author";
    }

    elseif ($choice=="5")

    {
    $Store_Name=$SS;
    $SQL_STATEMENT.="WHERE ((c.ISBN=a.ISBN) AND (c.Store_Code=b.Store_Code))";
    $SQL_STATEMENT.="AND $Store_Name=b.Store_Name";
    }


    $result=mysql_query($SQL_STATEMENT,$con);

    //now issue the sql query..

    if (mysql_num_rows>0)

    {

    // you have some results..

    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>");

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

    //loop through the items..

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


    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>");
    }

    else

    {
    echo "No resultsn";
    }

    }

    else

    {
    //user has not clicked on submit button..

    echo "Error!! Access Deniedn";
    exit;
    }

    ?>


    <!-- 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')">

    </BODY>


    </HTML>

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    112
    Rep Power
    14
    Hi

    I have had a quick look at your code and i think the problem is , as follows your "submit" button has the name 'action' so therefore in your code you need to use the name of the button:

    so instead of if(isset($submit)) { .......

    use if(isset($action)) { .......

    as in all of PHP the name of the form object then becomes a variable of the same name when the form is submitted.

    Also there is no real need to use the 'isset' function i always use if ($action) .. or whatever i have called my button. This is no bog deal though you should judt try what i said and see if it works,

    waseem

    visit http://www.itstop.com ,

    into sports ??? then goto
    http://www.sportwebpages.com
  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
    Thanks, but the table is still empty, I wonder why.

    Sorry I'm such a doofus but I'm brand new to PHP and I haven't programmed in a while.

    Any help from anyone would be deeply appreciated.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    France
    Posts
    16
    Rep Power
    0
    like waseem I think the pb is with the if(isset($action)).

    Try simply using :

    if ($action != "" ) {
    ....
    }

    When you press the submit button named action it will take the value specified in the value field of the corresponding <INPUT> tag.
    So when you sumblit the form $action="Submit".

    You can echo a value just after the test to see if it sucess.

    After this test if the table is still empty then the pb is due to your query.

    If this is due to your query echo the value of $SQL_STATEMENT.

    You can post the query if you need help debugging it.

    Hope this helps

    JB Lallement


Similar Threads

  1. [JS] Enable/disable submit button
    By mrbomb in forum HTML Programming
    Replies: 15
    Last Post: February 29th, 2004, 08:59 AM
  2. Replies: 3
    Last Post: February 22nd, 2004, 10:56 AM
  3. Submitting a form without a submit button
    By Monsieur in forum HTML Programming
    Replies: 7
    Last Post: February 11th, 2004, 12:18 PM
  4. Disabled submit button not submitting.
    By noleenm in forum HTML Programming
    Replies: 28
    Last Post: February 11th, 2004, 12:06 AM
  5. submit form w/o pressing a button
    By alzheimer in forum HTML Programming
    Replies: 2
    Last Post: February 1st, 2004, 07:53 AM

IMN logo majestic logo threadwatch logo seochat tools logo