Jump to content

And I present to you.. more n00b questions!


SephirGaine

Recommended Posts

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!
Link to comment
Share on other sites

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).
Link to comment
Share on other sites

[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
Link to comment
Share on other sites

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]


@orio

all the mysql_fetch_xxx() functions return false when there are no more records
Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.