SephirGaine Posted August 8, 2006 Share Posted August 8, 2006 Yeah. Most unfortunately. However, they [b]should[/b] be simple fixes, so I'll keep my fingers crossed for now and probably slap myself later when I realize how simply I messed up. BUT, here's what I've got. A dropdown box within a form. Within this dropdown box, it recalls data from a database. A work order number, the customer name, and whoever assigned that work. They select which work order they want to view, click submit, and it goes to an HTML file that generates the rest.I've got two problems that have stemmed since I've attempted this.The first, is that not all the word orders are displaying. When I had the list consisting of JUST the word order number, it displayed every work order within the database. However when I added more strings to the option, it only displays the first one.My second problem. I'm trying to assign the order number to a variable so I can carry it over to the next page. This is where I feel very, very stupid. I've used variables off of forms perfectly, however I figured just using $_POST on the first page and $_GET on the next would work. I was wrong apparently.Without further ado.. here's my code.[code]<form action="prevwor.php" method="post"><select name="prevwor3"><?php$query = "SELECT * FROM WOR";$resource = mysql_query($query) or die("Error: ". mysql_error() ." in query");if ($resource !== FALSE){ if ($num_open = mysql_fetch_assoc($resource)) { echo '<option>'.$num_open['work_order_num'].' - '.$num_open['Customer'].' - '.$num_open['EmpName'].'</option>'; }}?></select><?php$prevwor = $num_open['work_order_num'];$_POST["$prevwor"];?>[/code]And for the next page, pertaining to the second problem..[code]<?php$ordernum = Trim(stripslashes($_POST['$prevwor']));?>[/code]Thanks in advance! Quote Link to comment Share on other sites More sharing options...
bpops Posted August 8, 2006 Share Posted August 8, 2006 first problem:I don't usually use the mysql_fetch_assoc() function (and truth be told, i dont know what that does)... but I always use mysql_fetch_array()... you could try that and see if it works? Quote Link to comment Share on other sites More sharing options...
bpops Posted August 8, 2006 Share Posted August 8, 2006 second problem:I don't believe you need the dollar sign in the $_POST variable:[code=php:0]<?php$ordernum = Trim(stripslashes($_POST['prevwor']));?>[/code] Quote Link to comment Share on other sites More sharing options...
Orio Posted August 8, 2006 Share Posted August 8, 2006 I cant understand this line:if ($num_open = mysql_fetch_assoc($resource))mysql_fetch_assoc() doesnt reutn true or flase, it returns an array with the results.If you want to echo all the results, enter this line into a while loop.while($num_open = mysql_fetch_assoc($resource)){echo....Orio.EDIT- @bpops- you are wrong about the "second problem". everything is fine over there (maybe "trim" being "Trim" is a problem, but I dont know). Quote Link to comment Share on other sites More sharing options...
bpops Posted August 8, 2006 Share Posted August 8, 2006 [quote author=Orio link=topic=103466.msg411973#msg411973 date=1155067295]EDIT- @bpops- you are wrong about the "second problem". everything is fine over there (maybe "trim" being "Trim" is a problem, but I dont know).[/quote]ah, well i've never used that dollar sign in the post before, and it always worked for me. oh well Quote Link to comment Share on other sites More sharing options...
Barand Posted August 8, 2006 Share Posted August 8, 2006 Try[code]<form action="prevwor.php" method="post"><select name="prevwor3"><?php $query = "SELECT * FROM WOR"; $resource = mysql_query($query) or die("Error: ". mysql_error() ." in query"); if ($resource !== FALSE) { if ($num_open = mysql_fetch_assoc($resource)) do { echo "<option value='{$num_open['work_order_num']}'>".$num_open['work_order_num'].' - '.$num_open['Customer'].' - '.$num_open['EmpName'].'</option>'; } while ($num_open = mysql_fetch_assoc($resource)); }?></select><input type="submit" name="submit" value="Submit"></form>[/code]To process, note the select name is "prevwor3"[code]<?php$ordnum = $_POST['prevvor3'];echo $ordnum;?>[/code]@orioall the mysql_fetch_xxx() functions return false when there are no more records Quote Link to comment Share on other sites More sharing options...
SephirGaine Posted August 8, 2006 Author Share Posted August 8, 2006 [b]Barand,[/b] brilliant! The first part works just cool now, all the information is in the drop-down box and they all display correctly. However, the work order number is still having trouble being carried over to the next page. I've got the select name as prevwor3, and have this:[code]<?php$ordernum = $_POST['prevvor3'];?>[/code]Inside of prevwor.php. However, nothing is being assigned to the variable it seems. Nothing shows when I attempt to echo it. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 8, 2006 Share Posted August 8, 2006 check your spelling!$_POST['prevvor3']; vs prevwor3 note the v's and w's Quote Link to comment Share on other sites More sharing options...
SephirGaine Posted August 8, 2006 Author Share Posted August 8, 2006 ..d'oh! That was simple enough. Thank god you guys can see what I'm too ignorant to notice. ;) Thanks for the catch, and all the help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.