Solved

PHP - Using textbox value in SQL where clause

Posted on 2011-09-12
4
628 Views
Last Modified: 2012-05-12
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
Comment
Question by:deanlee17
  • 2
4 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36521526
$sql = "... WHERE `PrtNumber` = '$textboxvalue'";
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36521530
You didn't say which SQL you are using and which driver...
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 36521690
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
 

Author Comment

by:deanlee17
ID: 36522786
Thats great, thanks guys. Ray gave the best answer I think,
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question