I’m trying to design an inventory system and im running into problems with my code.
I have a page where I want to add a number of parts to a order. However, sometimes we may use 1 part, sometimes 2, sometimes three, or sometimes none at all. I am pulling the data I need out of the database, but, how do I add a additional array that is blank or maybe one that saids “Empty” when they user doenst need to add a part.
Or a custom option that is coded right into the php page. (prefer to put it at the top of the option list)
Here is my code:
include 'include/connect.php';
Part 1:<select size="1" name="part1">
<?
$opt = @mysql_query("SELECT * FROM inventory2 WHERE part_type='5' and availability>'0'");
if(@mysql_num_rows($opt) > 0){
while($opt_desc = @mysql_fetch_array($opt)){
?>
<option value="<?php echo $opt_desc[1] ?>"><? echo $opt_desc[2]; ?> - <? echo $opt_desc[4]; ?></option>
<? }} ?>
</select>
Part 2:<select size="1" name="part2">
<?
$opt = @mysql_query("SELECT * FROM inventory2 WHERE part_type='5' and availability>'0'");
if(@mysql_num_rows($opt) > 0){
while($opt_desc = @mysql_fetch_array($opt)){
?>
<option value="<?php echo $opt_desc[1] ?>"><? echo $opt_desc[2]; ?> - <? echo $opt_desc[4]; ?></option>
<? }} ?>
</select>
Part 3:<select size="1" name="part3">
<?
$opt = @mysql_query("SELECT * FROM inventory2 WHERE part_type='5' and availability>'0'");
if(@mysql_num_rows($opt) > 0){
while($opt_desc = @mysql_fetch_array($opt)){
?>
<option value="<?php echo $opt_desc[1] ?>"><? echo $opt_desc[2]; ?> - <? echo $opt_desc[4]; ?></option>
<? }} ?>
</select>
How to add blank and or custom values to my array
Moderator: General Moderators
Re: How to add blank and or custom values to my array
Why do you need the blank array?
Last edited by onion2k on Fri Apr 25, 2008 8:58 am, edited 1 time in total.
Reason: Adding a link to your site with no good reason is spamming. Don't do it again.
Reason: Adding a link to your site with no good reason is spamming. Don't do it again.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: How to add blank and or custom values to my array
To setup a single array:
To append to an array:
Code: Select all
$myArray=array('part'=>'empty');
Code: Select all
$myArray[]=array('part'=>'empty');
Re: How to add blank and or custom values to my array
It don’t seem to work. Here is a sample of what it does before I added the code you provided so you can visualize what I am trying to do.
Maybe I wasn’t adding the code to the correct spot or something.
http://www.codetest.info/sandbox/add.php
I’m still working on it displaying the correct seletion box as well once it brings you to the part that has all the data plugged in from the database. Im not sure how to do that either. It places the info in the database, but just not showing the option choice.
Maybe I wasn’t adding the code to the correct spot or something.
http://www.codetest.info/sandbox/add.php
I’m still working on it displaying the correct seletion box as well once it brings you to the part that has all the data plugged in from the database. Im not sure how to do that either. It places the info in the database, but just not showing the option choice.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: How to add blank and or custom values to my array
Post your new code.