Reputation Activity
-
webbie1985 reacted to inlinedivblock in Sorry to keep postingHi me again
mysql_real_escape_string(mysql_query("SELECT productdescription FROM products WHERE productcode = '{productcode}'")); May have overdone the mysqlrealescapestring, only really need to use it for inputting data into rows from user inputs. And i don't think you need to encapsualte the whole mysql_query
Your while loop is incomplete have a quick look at this for while loops http://www.tizag.com/phpT/whileloop.php
As for what you are trying to do you are going to need to use Ajax with Javascript to change values in from input field. This is a good place to start: http://www.w3schools.com/php/php_ajax_php.asp you can adapt the code there to suit your needs.
-
webbie1985 reacted to Chris Day in Sorry to keep postingthis should work for you:
<?php include ("db.php"); $prodsearch1 = mysql_real_escape_string($_POST['productcode']); $prodfind = mysql_query("SELECT productdescription FROM products WHERE productcode = '".$prodsearch1."'"); $row5 = mysql_fetch_array($prodfind); $row5 = $row5['productcode']; ?> Any user inputted text going into any query needs to be sanitized -
webbie1985 reacted to Chris Day in Sorry to keep postingput echo mysql_error(); just before the ?>
-
webbie1985 reacted to inlinedivblock in Sorry to keep postingare values being posted before you get to the page you have just displayed above? probably why you are not getting any results returned...
-
webbie1985 reacted to inlinedivblock in Sorry to keep postingyou might just have to post the id from another page or you can post on to itself to retireve the data if you don't want to use ajax!
-
webbie1985 reacted to Chris Day in Sorry to keep postingi would remove your DB details ASAP!
-
webbie1985 reacted to Chris Day in Sorry to keep postingno problem as for your question, what JQuery plugin are you using as you will have to bind a click event to fill in the data for you or do you have a live link?
-
webbie1985 reacted to Chris Day in Sorry to keep postingi get an error while loading jquery
Failed to load resource: the server responded with a status of 404 (Not Found) http://www.swifttrading.co.uk/pmanagement/jquery/js/jquery-1.4.2.min.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://www.swifttrading.co.uk/pmanagement/jquery/js/jquery-ui-1.8.2.custom.min.js -
webbie1985 reacted to inlinedivblock in Sorry to keep posting<?php $mysqli = new mysqli(); $text = $mysqli->real_escape_string($_GET['term']); $query = "SELECT * FROM products WHERE productcodes LIKE '%$text%' ORDER BY productcodes ASC"; $result = $mysqli->query($query); while($row = $result->fetch_assoc()) { ?> <script> $("input[type='text'][name='quantity']").keyup(function () { var value = $(this).val('<?php echo $row['qty']?>'); }).keyup(); $("input[type='text'][name='ponumber']").keyup(function () { var value = $(this).val('<?php echo $row['ponumber'] ?> '); }).keyup(); </script> <?php } ?>
This is with JQUERY it is the simplest solution i can come up with, it targets the INPUT fields with the relevant name that you have used and fills it in from the results returned on the search. You may want to limit results to 1 on the mysql query,
$row[''] <--- inside here you need to call the correct fiield name, not sure what you called them in your database, i just guessed
But this should help you understand how to fill it in live?
see it working here in theory http://jsfiddle.net/hdhJw/
-
webbie1985 got a reaction from fleur in Best book for learning JQueryi agree with stephenOC but try http://www.codecademy.com it teaches you what you need but you have to complete tasks to progress really good way of learning
-
haha no worries, i wasn't going to make big DEAL out of it, as i do it all the time...
You might want to think about securing the results, as the way it is coded it is open to hacking, someone can actually extract all your data the way you have it.
Have a look a little read of this http://php.net/manual/en/function.mysql-real-escape-string.php or lookup SQL Injection in google.