0

<?=$_SERVER?> refers to the same file, that is the same file currently being executed. suppose the code is in index.php, when you call <?=$_SERVER?> it means you are calling index.php

value="<?=$data?>"><?=$data fills html value with data from array with index id and name

hope you get it :)

hhhmmm.
nice to know. Ϋ

:) thanks evstevemd!

0

i haven't yet tried a dropdown list having options like that.
i also haven't yet seen any site using such.
but ey, it's a great idea! Ϋ

for now i could only offer you two dropdown lists;
first list for the category
then the second list for the printer model name but will basically depend on the selection from the first list.
such as this sample :

--- Select Printer Category --- [V]
- Inkjet Printer
- Color Printer
- Ribbon Printer

then for an instance that the Inkjet Printer category was selected ,
this would be the options for the second dropdown list which is for the printer model names available in the category of the Inkjet printers :

---Select Printer--- [V]
- s2134
- we462

that's it! Ϋ
'hope this helps.

hmmm.. i have thought about that as a solution but can you help me with the coding..
i know it will be a conditional statement. the printers in the drop down list will depend on what type of printer has been chosen..
thanks!!


@ evs:

thanks for that great info..

0

what does this mean:

action="<?=$_SERVER?>"

and this:

value="<?=$data?>"><?=$data

They ( <?=$something?> ) are PHP shorttags, and can be disabled on some server configurations. They basically an easier way of typing <?php echo $something; ?> and while most don't recommend them, I will stubbornly continue to use them until their deprecation in PHP6! :)

The first one outputs the address of the page, so the form submits itself to the page that created it. The second outputs the id and name values from the MySQL database. The $data variable is set to the values from each row of the MySQL query.

@ﻼim: Thanks! Back at ya!

EDIT:
@ev Sorry about that! I didn't see that you already answered the question. :P

Edited by FlashCreations: n/a

0

hmmm.. i have thought about that as a solution but can you help me with the coding..
i know it will be a conditional statement. the printers in the drop down list will depend on what type of printer has been chosen..
thanks!!


@ evs:

thanks for that great info..

hi there detweiller! Ϋ

here's the sample code for that :

- Select Printer -

	<form method = "post">
    <?php

		if($_POST['category'])
		{
			$cat = $_POST['category'];
			$_SESSION['cat'] = $cat;
		}

		if($_POST['supplier'])
		{
			$sup = $_POST['supplier'];
			$_SESSION['sup'] = $sup;
		}

		$query = mysql_query("SELECT distinct category from printers");

		echo "Category : <select name = category onchange = submit()>";

		if($cat == '')
		{
			echo "<option value = ''> Category </option>";
		}

		else
		{
			echo "<option value = '$cat'>$cat</option>";		
		}

		while($category = mysql_fetch_object($query))
		{				
			echo "<option value = '$category->category'>".$category->category."</option>";
		}		

		echo "</select><br><br>";

		$item = mysql_query("SELECT distinct supplier from printer where category = '$cat'");

		echo "Supplier : <select name = supplier onchange = submit()>";
	
		if($sup == '')
		{
			echo "<option value = ''>Supplier</option>";
		}
	
		else
		{
			echo "<option value = '$sup'>$sup</option>";		
		}

		while($supplier = mysql_fetch_object($item))
		{
			echo "<option value = '$supplier->supplier'>".$supplier->supplier."</option>";
		}			
		
		echo "</select><br><br>";	

		$categ = mysql_query("SELECT printer from printer where category = '$cat' and supplier = '$sup'");

		echo "Item Name : <select name = item>";
		echo "<option value = ''>Select Item</option>";	
		
		while($cate = mysql_fetch_object($categ))
		{
			echo "<option value = '$cate->printer'>".$cate->printer."</option>";
		}			
		
		echo "</select><br><br>";					

		echo "<center><input type = submit name = select value = 'Select'></center></form> ";
	
		if($_POST['select'])
		{
			if($qty == '' || $sup == '' || $item =='')
			{
				echo "<script type='text/javascript'>window.alert('Please Complete all the Fields.')</script>";
			}
	
			else
			{
				echo "<script type='text/javascript'>window.alert('Selected')</script>";
				$sup = $_SESSION['sup'];	
				$cat = $_SESSION['cat'];
				$item = $_POST['item'];

				mysql_query("insert into tbl_orders(category, supplier, item, quantity, date)
											 values('$cat', '$sup', '$item', $qty, '$date')");

				$selec = mysql_query("SELECT * from printer where category = '$cat' 
					and supplier = '$sup' and printer = '$item'");
					
				echo "<table align = center>
				<tr>
				<td><center><strong>Printer Name</strong></center></td>
				<td><center><strong>Printer Category</strong></center></td>
				<td><center><strong>Printer Supplier</strong></center></td>
				</tr></table>";
				
				echo "<table align = center>";
				while($prin = mysql_fetch_object($selec))
				{
					echo "<tr>";
					echo "<td><center>".$prin->printer."</td>";
					echo "<td><center>".$prin->category."</td>";
					echo "<td><center>".$prin->supplier."</td>";
					echo "</tr>";
				}
				
				echo "</table>":
			
				//echo "<META http-equiv='refresh' content='0;URL=purchase.php'>";
			}
		}

	?>
    </form>

:) sorry for taking long, got busy here in the office.
hope that helps.
good luck and happy day ahead!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.