Jump to content

Help with querying MySQL database with a form


Swerve1000

Recommended Posts

Hi,

 

I'm trying to create a webpage form which will query a database and post the results onto a webpage.

 

I'm trying to write the code for the form:-

 

 

 

<form name="searchform" method="POST" action="searchresults.php">

<p> First Name: <input name="First name" type="text" id="First name">

<p><input type="submit" name="submit" value="submit">

</form>

 

Can anyone tell me what the id 'thing/value' is/does? I need to use this I'm guessing for the SQL query.

 

I need to go through all of this stage by stage.

 

Many thanks!

 

 

 

 

 

 

 

id is typically used by javascript or CSS to uniquely identify an HTML tag.  It's nothing to do with SQL, although SQL very often has its own ids to uniquely identify a row of data.

 

So although it's "id", it's not related at all to the ids you see in SQL.  Its purpose is similar though - unique identification of a thing.

 

Hope that clarifies things!

I am not quite sure what your saying, but if you want information displayed that has been inserted by someone else all you need is PHP.

 

Try this coding.

 

<form method="POST" action="searchresults.php">
<p> First Name: <input name="firstname" type="text" />
<p><input type="submit" value="Submit" />
</form>

 

PHP CODE

<?php
$firstName = $_POST ['firstname'];
echo "First Name: $firstName";
?>

 

This code will take what the person entered on one page and insert it on another page. Now storing the information inserted by the person uses SQL, and thats a whole new set of coding. There is also a way to store the entered inormation, and then recall it when you need it. Like I said, that is all different coding that I am not very familiar with. Good luck finding everything else you need.

I am not quite sure what your saying, but if you want information displayed that has been inserted by someone else all you need is PHP.

 

Try this coding.

 

<form method="POST" action="searchresults.php">
<p> First Name: <input name="firstname" type="text" />
<p><input type="submit" value="Submit" />
</form>

 

PHP CODE

<?php
$firstName = $_POST ['firstname'];
echo "First Name: $firstName";
?>

 

This code will take what the person entered on one page and insert it on another page.

 

thanks for the great help!

 

So to view the results, I need to create a webpage called 'searchresults.php' and use some php code to place the results into the results page form, right? Such as ECHO or something I'm guessing

 

Thanks!

 

Do you want to store results that people will get when they search for something. Or do you want to store what people search for? Like if I search for hello, then my search query will be stored.

 

Hi,

 

Don't want to store anything, just want a user's search results to show the matching rows on a page.

 

:)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.