passing a query to another page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • backups2007
    New Member
    • Jul 2007
    • 92

    passing a query to another page

    is it possible to pass a query to another page?

    for example,

    page1.php
    Code:
    <form method='post' action='page2.php'>
    <?
         $query = mysql_query("SELECT * FROM tblProducts");
         ....
    ?>
    
    <input type='submit' onclick='page2.php'>
    
    </form>
    page2.php
    Code:
    <?
         $newquery = $_POST['query'];
    
        include("connect_db.php")
    
         $result = mysql_query($newquery);
    ?>
    Last edited by backups2007; Oct 30 '07, 09:17 AM. Reason: incomplete post
  • pritipshah
    New Member
    • Sep 2007
    • 11

    #2
    If you want to user $_POST['query'] in page2.php then you have to have hidden variable in first file named query and in that variable you have to set your value(i.e sql query)

    Regards,
    Priti

    Comment

    • backups2007
      New Member
      • Jul 2007
      • 92

      #3
      Originally posted by pritipshah
      If you want to user $_POST['query'] in page2.php then you have to have hidden variable in first file named query and in that variable you have to set your value(i.e sql query)

      Regards,
      Priti
      Thank you for your reply.

      Do you have any other suggestions aside from my post? Are there any other ways to pass queries?

      Comment

      • pritipshah
        New Member
        • Sep 2007
        • 11

        #4
        Hi backups2007,

        As per mine this is the only safe way to use query values from last page. you can't pass to in get value as it displays on toolbar and not the right way of codeing too.

        My suggesion to you is better to write a query on the same page where you want to run it because if lost connection or other tech problem will occure while redirecting the page then it will end to error.

        Regards,
        Priti

        Comment

        • backups2007
          New Member
          • Jul 2007
          • 92

          #5
          Originally posted by pritipshah
          Hi backups2007,

          As per mine this is the only safe way to use query values from last page. you can't pass to in get value as it displays on toolbar and not the right way of codeing too.

          My suggesion to you is better to write a query on the same page where you want to run it because if lost connection or other tech problem will occure while redirecting the page then it will end to error.

          Regards,
          Priti
          Here's the thing, the reason why I am asking about passing queries to another page is because I need to use it for a part of the system that I'm developing. It is for an exporting to excel option of my system. I want to use only one file that other pages can call to export contents from the database.

          Comment

          Working...