• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 846
  • Last Modified:

PHP - Using textbox value in SQL where clause

Hi Experts,

Im creating a PHP page that resturns database values, I went the WHERE clause of my SQL statement to pick up the value in a textbox.

In VB id do something like...

WHERE (PrtNumber = '" & FlxMestecReport(RowCount, 17) & "')"

How do you guys do it?

Thanks,
Dean.
0
deanlee17
Asked:
deanlee17
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
$sql = "... WHERE `PrtNumber` = '$textboxvalue'";
0
 
Dave BaldwinFixer of ProblemsCommented:
You didn't say which SQL you are using and which driver...
0
 
Ray PaseurCommented:
By "textbox" do you mean a form <input> control?  If so, you might have something like this

// THE ACTION SCRIPT
$x = mysql_real_escape_string($_GET["x"];
$q = "SELECT thing FROM mytable WHERE PrtNumber = '$x' LIMIT 1";
$r = mysql_query($q) or die( mysql_error() );
$n = mysql_num_rows($r);
if ($n) echo "I GOT ONE";
if (!$n) die( "I DID NOT FIND ANYTHING EQUAL TO $x" );
$s = mysql_fetch_assoc($r);
var_dump($s);

// THE FORM INPUT
<form>
<input name="x" />
<input type="submit" />
</form>
0
 
deanlee17Author Commented:
Thats great, thanks guys. Ray gave the best answer I think,
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now