1

I'm using this php code as part of App Inventor

$Techid = mysqli_real_escape_string($dbc, $_GET['Techid']);
$diffs = mysqli_real_escape_string($dbc, $_GET['diff']);
$values = mysqli_query($dbc, "SELECT * FROM CPETrack WHERE (Techid= '$Techid') AND (diff = '$diffs')");

The web url i need to parse over is: http://domainhere.com/custserv.php?id=1000&diff>=15

The techid is defined in app inventor itself and so is the diff.

I can do this in the mysql DB SELECT * FROM CPETrack WHERE id=1000 AND diff>=15; and it will return all items from the relevent id column and diff column greater than or equal to 15.

I'm unable to convert this to php thou to do the same job. How would I go about doing this?

Please bear in mind the actual diff value will be set within app inventor and I'm using set url1 to block in app inventor and join text block to create the web url and the php to give the result.

10
  • $_GET['diff'] doesn't exist, it's $_GET['diff>'] because URLs only recognise = as a separator between the key/value pair in the url Commented Mar 8, 2015 at 20:22
  • $diffs = mysqli_real_escape_string($dbc, $_GET['diff>']); This cannot be due to the fact that the $_GET['diff']; is the sql DB column name. Commented Mar 8, 2015 at 20:26
  • And now you're giving yourself diff = 15 in your SQL query..... do a bit of basic debugging, like var_dumping your $_GET Commented Mar 8, 2015 at 20:28
  • The idea is to get all diff column values over 15 from the db and show the result. It works in the sql screen when debugging, just doesnt translate to php and then into a usable URL Commented Mar 8, 2015 at 20:30
  • I can see what the idea is. I've told you what both problems are. I've told you how to debug it. Do you expect me to write it for you as well? Commented Mar 8, 2015 at 20:32

2 Answers 2

1

what about using >= in your php script like this

$values = mysqli_query($dbc, "... AND (diff >= '$diffs')");
Sign up to request clarification or add additional context in comments.

Comments

1

The answer was found at PHP MySQL: Query with Less Than AND Greater Than

Amended Php code to $values = mysqli_query($dbc, "SELECT * FROM CPETrack WHERE (Techid= '$Techid') AND (Type= '$cpe') AND (diff BETWEEN $diffs AND 100)");

I can now set the $diff value from the spinnerselection and the listpicker returns values between $diff value and 100.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.