Solved

PHP - Using textbox value in SQL where clause

Posted on 2011-09-12
4
691 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 110

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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

717 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