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!

 

 

 

 

 

 

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

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.

 

:)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.