4 Replies - 799 Views - Last Post: 29 February 2012 - 05:30 AM

#1 Silent_Symon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 22-February 12

View Database on same HTML page as submitting the data.

Posted 25 February 2012 - 07:02 PM

Hello all, I am working on a website and I am unsure of the html code needed to do the following:

I want to display a table of products that have been input using radio buttons that have been linkedPHP / SQL Querys on the same HTML page that I am submitting the data from.

I have got the table to display on a seperate .php page but I just need some help with the "Press to Search" button code (I assume its the form action part)

at the moment it is the following:

<form action="AllProducts.php" method="post">
<input type="radio" name="Price" value="AnyPrice" /> Any Price<br />
<input type="radio" name="Price" value="0-9" /> £0.99 - £9.99<br />
<input type="radio" name="Price" value="10-19" /> £10.00 - £19.99<br />
<input type = "submit" value = "Press to Search"></form>



many thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: View Database on same HTML page as submitting the data.

#2 Silent_Symon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 22-February 12

Re: View Database on same HTML page as submitting the data.

Posted 25 February 2012 - 07:13 PM

Sorry.. I have just read back what I wrote and have realised it doesn't make much sense, I can't find the edit button anywhere so I'll try again:

I'm creating a website that has a database embedded using PHP & SQL, I have the database running and can specify which results to display using radio buttons on my main HTML page (index.html), however when I click the "Press to Search" button, my "allProducts.php" page (where the table of the database is created) opens in a new page, what I would like is for this table to be displayed on the HTML page where I am submitting it from. (index.html)
Was This Post Helpful? 0
  • +
  • -

#3 Mahdi Eftekhari  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 19
  • Joined: 16-February 12

Re: View Database on same HTML page as submitting the data.

Posted 26 February 2012 - 03:38 AM

If you want your product to appear underneath your radio buttons you can use Ajax to do this for you. Basically what it does is to send the value of selected radio button to your php file and reads the value from it and displays wherever you want in the same page without refreshing the whole page.
Was This Post Helpful? 0
  • +
  • -

#4 hiddenghost  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 37
  • View blog
  • Posts: 599
  • Joined: 15-December 09

Re: View Database on same HTML page as submitting the data.

Posted 26 February 2012 - 10:25 PM

Change your code to:
<form action="index.php" method="post">
<input type="radio" name="Price" value="AnyPrice" /> Any Price<br />
<input type="radio" name="Price" value="0-9" /> £0.99 - £9.99<br />
<input type="radio" name="Price" value="10-19" /> £10.00 - £19.99<br />
<input type="hidden" name="submitted" value="yes" />
<input type = "submit" value = "Press to Search"></form>


Notice that the action is now set to index.php so it will just load itself and
there is a new field in the form of type hidden with a value of yes.

In your index.php script use this to get the display of what you want:
if('yes' === $_POST['submitted']){
include 'allProducts.php';
}



This is the smallest amount of code to get the results you want.
Not quite as cool as ajax, but it will work.
Was This Post Helpful? 0
  • +
  • -

#5 Silent_Symon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 22-February 12

Re: View Database on same HTML page as submitting the data.

Posted 29 February 2012 - 05:30 AM

Thank you for your reply, I did some research (the next morning) and found that I could use iframe to simply show the PHP output and embed that into a div tag to place it where I wanted it.

Thank you again

Symon
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1