Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
query results in new form and then submitted to new form
Old 09-25-2007, 05:22 PM query results in new form and then submitted to new form
Hank Scorpio's Avatar
Novice Talker

Posts: 11
Name: Hank Scorpio
Trades: 0
Hello All

I am trying to do something and may not be going about it the best way, either way I am stuck and am requesting help from you clever folks........

I am doing a small project for work, basically we have stock in the warehouse, there are locations where the item is picked and sent out to customers, and then there are backup locations for when the main picking location runs low/empty. Depending on how many units we stock of a certain item, it may have anything from 1 to even 10 backup locations. There is always only 1 picking location. Anyway, from time to time we find the numbers our system has are different to what is physically there, and have to generate a paperwork move, and then key it into the system to correct locations. The problem is, it's extremely difficult to get most staff to understand the stock moves to make things correct.

So I have been charged with the task of taking the thought (or lack of) out of the moves, and doing something semi-automated. Basically I think search box, linked to the stock database, queries database, returns result with all locations and their respective quantity's for that item number, then put's a text box next to each returned result so that the user can put the new qty in, submit it again and it will then generate a list of the moves that need doing by comparing the original database qty's with the new posted ones.

Using PHP and MySql I have managed to achieve the task of linking to the database, and producing a query that gives me all locations and quantity's of a specific item number. No problems so far.

Here is where it gets more complicated. I thought return the results in a new form, and then submit it and do the comparison. However, I just cant get my head around how to do this with different amounts of returned rows, then posting the data again. I am sure I will run into more probs once this is solved but for the time being thats where I am.

Below is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/
xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Item Number Search</title>
<link rel="stylesheet" href="display.css">
<?php
require_once ('./mysql_connect.php');
?>
</head>
<body>
<?php
//Check if form has been submitted.
if (isset($_POST['submitted'])) {
$errors = array();
if (empty($_POST['itemnumber'])) {
$errors[] = "You didn't enter an item number";
} else {
$in = trim($_POST['itemnumber']);
}
if (empty($errors)) {
$query = "SELECT location, qty FROM stock WHERE itemnumber = '".$_POST["itemnumber"]."' ORDER BY location ASC";
$result = @mysql_query ($query);
$num_rows = mysql_num_rows($result);
if ($result) {
echo '<div class="results"><form action="resultschange.php" method="post">
<tr>
<td><b>Location&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;</b></td><td><b>Qty&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;</b></td><td><b>New Qty&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;</b></td>
<br /><br /></tr>';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<tr><td>' .$row['location'] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;</td><td>' .$row['qty'] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;</td><td><input type="text" name="newqty"
id="newqty" size="5" maxlength="3" /></td><br /></tr>';
}
echo '<br /><br />' .$num_rows. '</div>';
mysql_free_result ($result);
echo '</form>';
}

mysql_close();
}

if (!empty($errors)) {
echo '<div class="results">
<p>';
foreach ($errors as $msg){
echo " - $msg</p></div>";}
}
}
?>
<div class="form">
<form action="locationsearch.php" method="post">
<p>Enter Item Number:<br />
<input type="text" name="itemnumber" id="itemnumber" size="30" maxlength="12" value="<?php if
(isset($_POST['itemnumber'])) echo $_POST['itemnumber']; ?>" />
<input type="submit" name="submit" id="submit" value="search" />
<input type="hidden" name="submitted" id="submitted" value="TRUE" />
</p>
</form>
</div>
</body>

I know some of the code needs tidying, at first it was all about seeing how far I could get, I will have a good tidy up before/if ever it goes live.

Sorry for the length of this post, if anyone can help much appreciated.
Hank Scorpio is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-26-2007, 12:32 AM Re: query results in new form and then submitted to new form
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I think I understand what you're trying to do, but I want to make sure I have it right.

You search an item which queries the database and returns a list of each location where the item is and a count. If one of the locations doesn't currently have the item does it return a 0 or is that location left off the list?

Along with the location and count is an input box so someone in any of the locations can update the count.

Is the problem then that when the person at one of the locations updates their count you're not sure how to compare it since it's one row vs many rows in the original form?

Do you need the counts from all locations in order to figure out the moves? If you need all locations reporting you might create a second table to hold the counts until you have them all or at least have the same number of total items in each table.

Could you describe a little how you know what moves to make based on the comparison?
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 09-26-2007, 10:54 AM Re: query results in new form and then submitted to new form
Hank Scorpio's Avatar
Novice Talker

Posts: 11
Name: Hank Scorpio
Trades: 0
Hi Vangogh

I'll give a bit more info:

Basically the stock system in place is not the most versatile or useful, and requires thought beyond the qty's the staff member can see in front of them. We are a 3rd party w/house so unfortunately stuck with what the client company have in place. We have two types of move, a W1 where you can move stock on the system from say location ABC to DEF. And a W2, which means you can basically create stock out of thin air, so if something was counted in as 10 in the first place and we now discover we have 15, we would W2 5 extra on, providing all other locations are correct. Because the issue gets complicated due to timing with picking and the useless system in place not always displaying enough info, some people are making complete mess up of the stock moves they are doing and we are ending up with some very strange figures. I am trying to take the thought out of it for them (as much as possible).

I get the stock info from a system created report, and then import it into the stock database, no probs there. If a reserve location has 0 stock it will not show up in the database, only the forward picking locations will show with a zero, this is because forward picking locations are live for as long as that item is bought by the buyers, without ever changing. Reserve locations come and go, so just drop off the system when empty.

You are right, the results are displayed by location and qty, with a text box next to it for a new qty for that item.

So Basically I see it like this:
__________________________________________________ _____________
Enter stock item.

Return results with text box for new qty

Type in new qty and submit

Comparison done between previous qty and new qty and result displayed telling user what move with qty needs to be made to get the old figure to represent the new one.
__________________________________________________ ______________

We dont need figures for every location, if it hasn't been counted then its assumed for that moment that its correct until it is counted (often a problem will only come to light becasue that location has been visited to pick from reserve to move to the forward picking area).

What I am struggling with is the syntax to make the second form.

The query results display in the second form. I dont know how to make the input for the text boxes based on how many result are returned.

So say the item abc123 had a forward location, and two reserve locations, I dont know how to make the text box reference for posting and comparing with the original.

Item: ABC123

Loc Qty New Qty

02abc 5 7
22def 12 10
22ghi 20 20

I want to post the above, so that the result comes back W1 stock move qty of 2 from 22def (reserve) to 02abc (forward). 22ghi is fine so no move.

I hope I have explained properly, I know its a bit of a ramble, but I really want this to work.
Hank Scorpio is offline
Reply With Quote
View Public Profile
 
Old 09-26-2007, 06:56 PM Re: query results in new form and then submitted to new form
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Thanks for the extra info. I'm not sure if this will work, but here's what I'm thinking.

What if next to the results from the original form you added two input boxes. One would be for the item count and the other would be for the location.

Then when that second form is submitted you should able to compare the new input values with the specific row from the database using a WHERE clause in your SQL.

Will that work? Is it the code you're struggling with or the concept?

I guess I'm only working on the concept part for now, but will do what I can to help with the code if you need.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 09-27-2007, 03:58 PM Re: query results in new form and then submitted to new form
Hank Scorpio's Avatar
Novice Talker

Posts: 11
Name: Hank Scorpio
Trades: 0
Hi Vangogh

Thanks for all your help, that sounds the best way to go.

Unfortunately, my company have now told me that I am not allowed to download WAMP to do this project. My manager has tried to persuade the IT team but they are having none of it.

Seems that they don't know what WAMP is and hear the word download and panic. Even though they have an internet "cafe" where people download numerous things which go against the IT code of conduct, I try to get a tool to improve things for the company which is not going to cost any money at all, save a load of time and in the long run money, and I have now been told "yeah we still want you to do it, but with excel."

I have not very much experience with VBA so it's probably not going to happen too quickly.

I am really dissapointed, but tempted to carry on for my own satisfaction of being able to do it, outside of work.

I really appreciate the help you have given me, I am just a bit narked that it is all for naught at the moment.

Once again thanks for your help and time on this.

Many Thanks
Hank Scorpio is offline
Reply With Quote
View Public Profile
 
Old 09-28-2007, 12:40 AM Re: query results in new form and then submitted to new form
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Sorry to hear you won't be able to work on this officially. Maybe you'll have fun working on it at home. If you're up for it you can actually download Apache and PHP and set up a server on your home computer. It's not the easiest thing in the world to set up, but it's not too hard either.

I was happy to help and if you decide to tr this at home and have questions ask away.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to query results in new form and then submitted to new form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34295 seconds with 12 queries