6 Replies - 634 Views - Last Post: 28 December 2009 - 07:53 PM Rate Topic: -----

#1 raven21  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 28-July 09

drop down menu

Post icon  Posted 27 December 2009 - 10:42 PM


<?php
																											   
   include_once('includes/ffe/ffeheader.html');
   include_once('includes/myclass.php');
   require_once('includes/ffe/ffe_connect.php');

   $op = stripslashes($_GET['op']);
   $id = stripslashes($_GET['id']);

   if (isset($_POST['add']) || isset($_POST['save'])) {
	  $error = false;
	  if (empty($_POST['category'])) {
		 echo '<p class="error_msg">Please enter category information!</p>';
		 $error = true;
	  }
	  $type = $_POST['type'];

	  $brand = $_POST['brand'];

	  $model = $_POST['model'];


	  if (!$error) {
	 if (isset($_POST['add'])) {
			$query2 = "INSERT INTO ffecategory (type, brand, model)
					   VALUES (ucase('$type'),ucase('$brand'),ucase('$model'))";
	 } else {
		$query2 = 'UPDATE ffevendor SET type=ucase("'.$type.'"),
											contact=ucase("'.$brand.'"),
											contact_no=ucase("'.$model.'") WHERE cat_id='.$_POST['hid'];
	 }
		 $result2 = @mysql_query($query2); 
	 if (!$result2)
			echo '<p class="error_msg">Error while saving supplier or brand!</p>'; 
	 else {
			header ("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/vendors.php?op=".$_POST['hop']."&id=".$_POST['hid']);
		exit();
	 }
	  }
   } // isset($_POST['add'])hy

   echo '<form action="vendors.php" method="post">

	 <input type="hidden" name="hop" value="'.$op.'" />
	 <input type="hidden" name="hid" value="'.$id.'" />

	 <table border="0" align="center" width="96%" bordercolor="#FFFFFF" bgcolor="#E0E0E0">
	   <tr bgcolor="#F0F0F0"><td class="ffetitle" colspan="3">Supplier / Brand</td></tr>
	   <tr bgcolor="#FFFFFF">
		 <td>
		   <table border="0" width="100%">
			 <tr>
		 	   <td width="80" valign="middle">
		   		 <table border="0" align="left" bordercolor="#999999" bgcolor="#999999" width="100%">
				   <tr bgcolor="#FFFFFF">
				 <td align="center"><a href="utilities.php" class="ffelink1">Return</a></td>
				<td align="center"><a href="vendors.php" class="ffelink1">Add Category</a></td>
				 <td align="center"><a href="update.php" class="ffelink1">Update Category</a></td>
 			   </tr>
				 </table>
		 	   </td>
			   <td align="right">

		   <!--
					 <table border="0" align="right">
					   <tr>
						 <td>
			   <input type="text" name="searchstring" size="20" maxlength="20" />
			   <input type="submit" name="search" value="Search" />
   				 </td>
					   </tr>
					 </table>
		   -->

			   </td>
			 </tr>
 		   </table>
		 </td>
	   </tr>
	   <tr bgcolor="#FFFFFF">
		 <td colspan="3">
		   <br><br>';

	 	if ($op=="edit") {		
				   $query = 'SELECT type,brand, model FROM ffevendor WHERE cat_id='.$id;
				   $result = @mysql_query($query);
		   if ($row = @mysql_fetch_array($result)) {
					  $type = $row[2];					
						$brand = $row[3];
					  $model = $row[4];

		   } 
		} else {
   			   $type = $_POST['type']; 
			   $brand = $_POST['brand'];
				 $model = $_POST['model'];
			   
		}

   echo '	   <table border="0" width="530" align="center" cellspacing="1">
		  <col width="100" align="right">
				  <col width="410" align="left">
				   [color=#FF0000]<tr><td>Category</td>
					  <td>';

						$category = new WEMSControls();
						$category->category($_POST['cat_id'],1);

   echo '			 </td>
				  </tr>[/color]				  
				  <tr><td>Type </td>
					 <td><input type="text" name="type" size="60" maxlength="60" value="'.$type.'"/></td>
				  </tr>
				  <tr><td>Brand </td>
					 <td><input type="text" name="brand" size="60" maxlength="60" value="'.$brand.'"/></td>
				  </tr>
			  <tr><td>Model </td>
					 <td><input type="text" name="model" size="30" maxlength="30" value="'.$model.'"/></td> </tr>
					<tr>
			 <td colspan="2" align="center">
			<br>';
			if ($op=="add") echo ' <input type="submit" name="add" value=" Add " />';
				else echo '<input type="submit" name="save" value=" Save " />';
   echo '		 </td>
		  </tr>';

   echo '	   </table>
		   <br><br>
		   <table border="0" width="99%" align="center" cellspacing="1" bordercolor="#ffffff">';

		 $query = 'SELECT * FROM ffecategory order by cat_id ASC';
		 $result = @mysql_query($query);

   echo '	 <tr bgcolor="#FFDDBB" align="center">
		   <td>ID</td>
		   <td>Category</td>
		   <td>Type</td>
		   <td>Brand</td>
		   <td>Model</td>

		 </tr>';

				 $bg = '#eeeeee';
				 while ($row = @mysql_fetch_array($result, MYSQL_NUM)) {
					$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');	 // switch the background color

					echo '<tr align="left" bgcolor="', $bg, '">';
			echo '  <td class="listtd">
				<a href="vendors.php?op=edit&id='.$row[0].'">',$row[0],'</a>
				</td>
							<td class="listtd">
				<a href="vendors.php?op=edit&id='.$row[0].'">',$row[1],'</a>
				</td>
				<td class="listtd">',$row[2],'</td>
							<td class="listtd">',$row[3],'</td>
							<td class="listtd">',$row[4],'</td>';
	   		   
			echo '</tr>';
		 } // while 


   echo '	  </table>

			   <br>
		 </td>
	   </tr>
		 </table>

	 </form>';

   include_once('includes/ffe/ffefooter.html');
   include_once('includes/footer.html');
																															 
?>





- how can i let the category drop down appear? i want that the list of the drop down came from the database. im having a hard time to show the database list of CATEGORY for a drop down. Please i need help, really.. :(

This post has been edited by raven21: 27 December 2009 - 10:43 PM


Is This A Good Question/Topic? 0
  • +

Replies To: drop down menu

#2 raven21  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 28-July 09

Re: drop down menu

Posted 27 December 2009 - 11:14 PM


<?php
																											   
   include_once('includes/ffe/ffeheader.html');
   include_once('includes/myclass.php');
   require_once('includes/ffe/ffe_connect.php');

   $op = stripslashes($_GET['op']);
   $id = stripslashes($_GET['id']);

   if (isset($_POST['add']) || isset($_POST['save'])) {
	  $error = false;
	  if (empty($_POST['category'])) {
		 echo '<p class="error_msg">Please enter category information!</p>';
		 $error = true;
	  }
	  $type = $_POST['type'];

	  $brand = $_POST['brand'];

	  $model = $_POST['model'];


	  if (!$error) {
	 if (isset($_POST['add'])) {
			$query2 = "INSERT INTO ffecategory (type, brand, model)
					   VALUES (ucase('$type'),ucase('$brand'),ucase('$model'))";
	 } else {
		$query2 = 'UPDATE ffevendor SET type=ucase("'.$type.'"),
											contact=ucase("'.$brand.'"),
											contact_no=ucase("'.$model.'") WHERE cat_id='.$_POST['hid'];
	 }
		 $result2 = @mysql_query($query2); 
	 if (!$result2)
			echo '<p class="error_msg">Error while saving supplier or brand!</p>'; 
	 else {
			header ("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/vendors.php?op=".$_POST['hop']."&id=".$_POST['hid']);
		exit();
	 }
	  }
   } // isset($_POST['add'])hy

   echo '<form action="vendors.php" method="post">

	 <input type="hidden" name="hop" value="'.$op.'" />
	 <input type="hidden" name="hid" value="'.$id.'" />

	 <table border="0" align="center" width="96%" bordercolor="#FFFFFF" bgcolor="#E0E0E0">
	   <tr bgcolor="#F0F0F0"><td class="ffetitle" colspan="3">Supplier / Brand</td></tr>
	   <tr bgcolor="#FFFFFF">
		 <td>
		   <table border="0" width="100%">
			 <tr>
		 	   <td width="80" valign="middle">
		   		 <table border="0" align="left" bordercolor="#999999" bgcolor="#999999" width="100%">
				   <tr bgcolor="#FFFFFF">
				 <td align="center"><a href="utilities.php" class="ffelink1">Return</a></td>
				<td align="center"><a href="vendors.php" class="ffelink1">Add Category</a></td>
				 <td align="center"><a href="update.php" class="ffelink1">Update Category</a></td>
 			   </tr>
				 </table>
		 	   </td>
			   <td align="right">

		   <!--
					 <table border="0" align="right">
					   <tr>
						 <td>
			   <input type="text" name="searchstring" size="20" maxlength="20" />
			   <input type="submit" name="search" value="Search" />
   				 </td>
					   </tr>
					 </table>
		   -->

			   </td>
			 </tr>
 		   </table>
		 </td>
	   </tr>
	   <tr bgcolor="#FFFFFF">
		 <td colspan="3">
		   <br><br>';

	 	if ($op=="edit") {		
				   $query = 'SELECT type,brand, model FROM ffevendor WHERE cat_id='.$id;
				   $result = @mysql_query($query);
		   if ($row = @mysql_fetch_array($result)) {
					  $type = $row[2];					
						$brand = $row[3];
					  $model = $row[4];

		   } 
		} else {
   			   $type = $_POST['type']; 
			   $brand = $_POST['brand'];
				 $model = $_POST['model'];
			   
		}

   echo '	   <table border="0" width="530" align="center" cellspacing="1">
		  <col width="100" align="right">
				  <col width="410" align="left">
				   [color=#FF0000]<tr><td>Category</td>
					  <td>';

						$category = new WEMSControls();
						$category->category($_POST['cat_id'],1);

   echo '			 </td>
				  </tr>[/color]				  
				  <tr><td>Type </td>
					 <td><input type="text" name="type" size="60" maxlength="60" value="'.$type.'"/></td>
				  </tr>
				  <tr><td>Brand </td>
					 <td><input type="text" name="brand" size="60" maxlength="60" value="'.$brand.'"/></td>
				  </tr>
			  <tr><td>Model </td>
					 <td><input type="text" name="model" size="30" maxlength="30" value="'.$model.'"/></td> </tr>
					<tr>
			 <td colspan="2" align="center">
			<br>';
			if ($op=="add") echo ' <input type="submit" name="add" value=" Add " />';
				else echo '<input type="submit" name="save" value=" Save " />';
   echo '		 </td>
		  </tr>';

   echo '	   </table>
		   <br><br>
		   <table border="0" width="99%" align="center" cellspacing="1" bordercolor="#ffffff">';

		 $query = 'SELECT * FROM ffecategory order by cat_id ASC';
		 $result = @mysql_query($query);

   echo '	 <tr bgcolor="#FFDDBB" align="center">
		   <td>ID</td>
		   <td>Category</td>
		   <td>Type</td>
		   <td>Brand</td>
		   <td>Model</td>

		 </tr>';

				 $bg = '#eeeeee';
				 while ($row = @mysql_fetch_array($result, MYSQL_NUM)) {
					$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');	 // switch the background color

					echo '<tr align="left" bgcolor="', $bg, '">';
			echo '  <td class="listtd">
				<a href="vendors.php?op=edit&id='.$row[0].'">',$row[0],'</a>
				</td>
							<td class="listtd">
				<a href="vendors.php?op=edit&id='.$row[0].'">',$row[1],'</a>
				</td>
				<td class="listtd">',$row[2],'</td>
							<td class="listtd">',$row[3],'</td>
							<td class="listtd">',$row[4],'</td>';
	   		   
			echo '</tr>';
		 } // while 


   echo '	  </table>

			   <br>
		 </td>
	   </tr>
		 </table>

	 </form>';

   include_once('includes/ffe/ffefooter.html');
   include_once('includes/footer.html');
																															 
?>





- how can i let the category drop down appear? i want that the list of the drop down came from the database. im having a hard time to show the database list of CATEGORY for a drop down. Please i need help, really.. :(
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: drop down menu

Posted 27 December 2009 - 11:25 PM

Topics merged, please dont create duplicate topics in multiple forums :)
Was This Post Helpful? 0
  • +
  • -

#4 raven21  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 28-July 09

Re: drop down menu

Posted 27 December 2009 - 11:37 PM

<?php

																															 
   include_once('includes/ffe/ffeheader.html');
   include_once('includes/myclass.php');
   require_once('includes/ffe/ffe_connect.php');

   $op = stripslashes($_GET['op']);
   $id = stripslashes($_GET['id']);

   if (isset($_POST['add']) || isset($_POST['save'])) {
	  $error = false;
	  if (empty($_POST[''])) {
		 echo '<p class="error_msg">Please enter category information!</p>';
		 $error = true;
	  }
	  $type = $_POST['type'];

	  $brand = $_POST['brand'];

	  $model = $_POST['model'];


	  if (!$error) {
	 if (isset($_POST['add'])) {
			$query2 = "INSERT INTO 'ffecategory' VALUES (1,ucase('$type'),ucase('$brand'),ucase('$model'))";
	 } else {
		$query2 = 'UPDATE ffevendor SET type=ucase("'.$type.'"),
											contact=ucase("'.$brand.'"),
											contact_no=ucase("'.$model.'") WHERE cat_id='.$_POST['hid'];
	 }
		 $result2 = @mysql_query($query2); 
	 if (!$result2)
			echo '<p class="error_msg">Error while saving supplier or brand!</p>'; 
	 else {
			header ("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/vendors.php?op=".$_POST['hop']."&id=".$_POST['hid']);
		exit();
	 }
	  }
   } // isset($_POST['add'])hy

   echo '<form action="update.php" method="post">

	 <input type="hidden" name="hop" value="'.$op.'" />
	 <input type="hidden" name="hid" value="'.$id.'" />

	 <table border="0" align="center" width="96%" bordercolor="#FFFFFF" bgcolor="#E0E0E0">
	   <tr bgcolor="#F0F0F0"><td class="ffetitle" colspan="3">Supplier / Brand</td></tr>
	   <tr bgcolor="#FFFFFF">
		 <td>
		   <table border="0" width="100%">
			 <tr>
		 	   <td width="80" valign="middle">
		   		 <table border="0" align="left" bordercolor="#999999" bgcolor="#999999" width="100%">
				   <tr bgcolor="#FFFFFF">
				 <td align="center"><a href="utilities.php" class="ffelink1">Return</a></td>
				<td align="center"><a href="vendors.php" class="ffelink1">Add Category</a></td>
				 <td align="center"><a href="update.php" class="ffelink1">Update Category</a></td>
 			   </tr>
				 </table>
		 	   </td>
			   <td align="right">

		   <!--
					 <table border="0" align="right">
					   <tr>
						 <td>
			   <input type="text" name="searchstring" size="20" maxlength="20" />
			   <input type="submit" name="search" value="Search" />
   				 </td>
					   </tr>
					 </table>
		   -->

			   </td>
			 </tr>
 		   </table>
		 </td>
	   </tr>
	   <tr bgcolor="#FFFFFF">
		 <td colspan="3">
		   <br><br>';

	 	if ($op=="edit") {		
				   $query = 'SELECT type,brand, model FROM ffevendor WHERE cat_id='.$id;
				   $result = @mysql_query($query);
		   if ($row = @mysql_fetch_array($result)) {
					  $type = $row[2];					
						$brand = $row[3];
					  $model = $row[4];

		   } 
		} else {
   			   $type = $_POST['type']; 
			   $brand = $_POST['brand'];
				 $model = $_POST['model'];
			   
		}

   echo '	   <table border="0" width="530" align="center" cellspacing="1">
		  <col width="100" align="right">
				  <col width="410" align="left">
				  <tr>
				  <td>
						$results = mysql_query("SELECT cat_id, category FROM `ffecategory`");

							if(mysql_num_rows($results) > 1){
							 
								echo("<select name=\"category\">");
							 
									while($row = mysql_fetch_object($results)){
							   
									 echo"<option value=\"$row->cat_id\">$row->category</option>";
							  }
							  echo "</select>";
							}
							else
								{
								  echo("<i>No values found.</i>");
								}
					</td>
				  </tr>
				  
				  <tr><td>Type </td>
					 <td><input type="text" name="type" size="60" maxlength="60" value="'.$type.'"/></td>
				  </tr>
				  <tr><td>Brand </td>
					 <td><input type="text" name="brand" size="60" maxlength="60" value="'.$brand.'"/></td>
				  </tr>
			  <tr><td>Model </td>
					 <td><input type="text" name="model" size="30" maxlength="30" value="'.$model.'"/></td> </tr>
					<tr>
			 <td colspan="2" align="center">
			<br>';
			if ($op=="add") echo ' <input type="submit" name="add" value=" Add " />';
				else echo '<input type="submit" name="save" value=" Save " />';
   echo '		 </td>
		  </tr>';

   echo '	   </table>
		   <br><br>
		   <table border="0" width="99%" align="center" cellspacing="1" bordercolor="#ffffff">';

		 $query = 'SELECT * FROM ffecategory order by cat_id ASC';
		 $result = @mysql_query($query);

   echo '	 <tr bgcolor="#FFDDBB" align="center">
		   <td>ID</td>
		   <td>Category</td>
		   <td>Type</td>
		   <td>Brand</td>
		   <td>Model</td>

		 </tr>';

				 $bg = '#eeeeee';
				 while ($row = @mysql_fetch_array($result, MYSQL_NUM)) {
					$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');	 // switch the background color

					echo '<tr align="left" bgcolor="', $bg, '">';
			echo '  <td class="listtd">
				<a href="vendors.php?op=edit&id='.$row[0].'">',$row[0],'</a>
				</td>
							<td class="listtd">
				<a href="vendors.php?op=edit&id='.$row[0].'">',$row[1],'</a>
				</td>
				<td class="listtd">',$row[2],'</td>
							<td class="listtd">',$row[3],'</td>
							<td class="listtd">',$row[4],'</td>';
	   		   
			echo '</tr>';
		 } // while 


   echo '	  </table>

			   <br>
		 </td>
	   </tr>
		 </table>

	 </form>';

   include_once('includes/ffe/ffefooter.html');
   include_once('includes/footer.html');
																															 
?>



Admin Edit: Please use code tags when posting your code. Code tags are used like so => :code: Thanks, PsychoCoder :)

This post has been edited by PsychoCoder: 27 December 2009 - 11:42 PM

Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: drop down menu

Posted 27 December 2009 - 11:44 PM

Now I know you're new here so I gave you the benefit of the doubt with the first 2 duplicate threads. Now I have merged a third thread regarding this same exact issue. Please stop making duplicate topics, I am asking nicely this time, but I cannot promise I will be so polite next time :)
Was This Post Helpful? 0
  • +
  • -

#6 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: drop down menu

Posted 28 December 2009 - 02:10 AM

Quote

how can i let the category drop down appear?

Where do you want to show the dropdown list in your page,
and it is same as show data into a table
here is an example:
$cat_query = mysql_query("SELECT * FROM tbl_cats")or die(mysql_error());
$cat = "<select name='cats' id='cats>";
if(mysql_num_rows($cat_query)>0){
	while($fetch = mysql_fetch_assoc($cat_query)){
		$cat .= "<option value='".$fetch['ID']."'>".$fetch['Title']."</option>"
	}
}
$cat .= "</select>";

Was This Post Helpful? 0
  • +
  • -

#7 raven21  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 28-July 09

Re: drop down menu

Posted 28 December 2009 - 07:53 PM

im so sorry... I thought i made the right thing... I was pasting this in database section because somebody told me so. That's what i did and mistakenly do pasting in the same forum. Im so sorry


i want it to appear above the other fields. that will be save when selected
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1