Jump to content

Mysqli Query (Inserting Variable)


airsoft4you

Recommended Posts

Evening all

 

I am pretty sure it is a fairly basic question however after countless searches of the forum and google I cannot seem to find an answer that I can understand.

 

So the overall aim of this little project is to have a web application where I can scan in the barcode of a product and it will then return the product title, the user then has to confirm that this is the correct product.

 

They then are presented with a input box where they enter the number of products they are wanting to add then click submit and the record is updated in the database.

 

Now I am having trouble taking a POST value that is submitted by the user and inserting that variable into a new query.

<?php
error_reporting(0);
require 'db/connect.php';

if ($result = $db->query("SELECT name FROM ps_product_lang WHERE id_product=$barcode"))
{
	if($result->num_rows){

		$rows = $result->fetch_object();
	
		echo $rows-> name;
	}
}

?>

the variable name is $barcode

 

Can anyone help at all, if you need any more information please ask

 

Kind Regards

 

Toby

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...