0

hello everyone, im a new member here and also new to php.

i've been searching in this site for days about my problem and with no luck i dont find any of them.

i want to create a dropdown list menu (of persons) and everytime i choose a name of a person in that dropdown list it will display information of that person from a database.
and can i create the list found in the dropdown menu will be the list of names(primary key) of the table?

db table name will be person
Primary key of the table will be Name

can anyone help me with the code.

thanks in advance!!

Edited by detweiller: n/a

4
Contributors
35
Replies
36
Views
7 Years
Discussion Span
Last Post by ﻼim
0

Something like this will have to be achieved with a combination of AJAX and PHP. The frontend (JavaScript) will call your backend (PHP) with a request when a new name is selected from the list. At its most basic form, that would like something like this:

<?php
//If a name was requested
if(isset($_GET['name'])) {
    //Connect to MySQL and select DB
    @mysql_connect($dbHost, $dbUser, $dbPass) or die('{result: -1');
    @mysql_select_db($db) or die('{result: -1}');
    //Get details on person via MySQL query
    $result = @mysql_query('SELECT data FROM person WHERE Name="'.mysql_real_escape_string($_GET['name']).'" LIMIT 1');

    //Return an error if person wasn't found
    if(mysql_num_rows($result) == 0) {
        die('{result: 0}');
    }
    //Otherwise, return user details
    $person = mysql_fetch_array($result);
    die('{"result": 1, "data": "'.$person['data'].'"}');
}
?>
<!doctype html>
<html>
<head>
<title>Person Information</title>
<script>
document.onload = function() {
    var x, details = document.getElementById('details');
    document.getElementById('pSelect').onchange = function() {
        if(window.XMLHttpRequest) {
            x = new XMLHttpRequest();
        } else {
            x = new ActiveXObject("Microsoft.XMLHTTP");
        }
        x.open("GET", "<?=$_SERVER['PHP_SELF']?>?name="+escape(this.value), true);
        x.onreadystatechange = function() {
            if(this.readyState == 4) {
                response = eval('('+this.responseText+')');
                if(response.result == -1) {
                    details.innerHTML = '<em>There was an error with your request.</em>';
                } else if(response.result == 0) {
                    details.innerHTML = '<em>Person was not found</em>';
                } else {
                    details.innerHTML = response.data;
                }
            }
        };
        x.send();
    };
};
</script>
</head>
<body>
<p>Person: <select name="person" id="pSelect"><option name="Bob">Bob Doe</option></select></p>

<div id="details"></div>
</body>
</html>

I've combined the backend and frontend into one file, but you can just as easily separate them if you wish. The JavaScript can also be sped up with the help of a library such as JQuery. Of course, the MySQL query will need a little work. You will need to request the data you would like to return and build & return that in PHP. You can also just request the data and build the result in JavaScript which would probably be more compliant with coding standards (separating presentation from code).
If you absolutely need, backwards compatibility for those few who don't have JS enabled, write back and I'll show you how to work it in.

All the Best,
PhpMyCoder

Edited by FlashCreations: n/a

0

thanks man for the code. I understand the PHP code part but not the Script code.

is there a way that it can only be coded it into javascript or php alone or both?? i mean you'll only those two. i'm really not familiar with that XMLHttpRequest, and ActiveXObject. i'm only familiar with php, javascript and mysql codes but i'm just a beginner. i'm willing to learn that too but not now.

thanks again!!

0

i hope this helps. :icon_wink:

<!-- select field and query -->
								<form method="post">	
										<br>
											<select name="theName" width = "200">
											<option value=''> Names  </option>
											
											<!-- names display -->
											<?php
				
												$myquery=mysql_query("SELECT distinct Name
														from person
														");
																		
													if(mysql_fetch_object($myquery) == null)
													{
														echo "<option value=''> No Record Found. </option>";
													}
																		
													else
													{	
																		
														$myquery=mysql_query("SELECT distinct Name
																				from person
																				");	
																									
														while($name=mysql_fetch_object($myquery))
														{
															echo "<option value='$name->Name'>".$name->Name."</option>";
														}
													} 
													
											?>
											
											</select>
										
										<input type="submit" name="view" value="  View  ">
								</form>
								
<?php
					if($_POST['view'])
					{
										$name = $_POST['theName'];

										if($name == null)
										{
											echo "<script type='text/javascript'>window.alert('Please check your input.')</script>";
											//echo "<META http-equiv='refresh' content='0; URL=index.php'>";
										}
										
										else if($name != null)
										{
											
											$myquery=mysql_query("SELECT  * from person");
						
												if(mysql_fetch_object($myquery) == null)
												{
													echo "<center>No Record Found.</center>"; // ---> this is if the person table have no values
												}
												
												else
												{
															 $myquery=mysql_query("SELECT  distinct Name
																from person
																where Name = '$name'
																");
																
																while($n=mysql_fetch_object($myquery))
																{
																	echo " <center> ";
																	echo " <font color = 'red'>Name : </font>".$n->Name;
																}
															 
													echo " 
													<br>
													<center>
													<table class = sample align=center width=1350px height = 50>
													<tr bgcolor = '#82CAFA'>
													<td width='50' align = 'center'> - </center></td>
													<td width='250' align = 'center'>NAME</center></td>
													<td width='50'><center>AGE</center></td> <!-- sample details from here -->
													<td width='50'><center>BIRTHDAY</center></td>
													<td width='50'><center>SEX</center></td>
													</tr><tr></tr>";
															
															$myquery=mysql_query("SELECT  Name, Age, Birthday, Sex
															from person
															where Name like '$name'
															order by Name");
							
									$check=0;
									while($n=mysql_fetch_object($myquery))
									{
										
										$check++;
										
										//---- name ----
										echo "<tr>";
										echo "<td align = right width='50'>$check</td>";
										echo "<td width='250' align = left>".$n->Name."</td>";
										if ($n->Age == 0  || $n->Age == null) // ---> sample details and column names from here
										{
											echo "<td width='50' align = center><font color = red>"." - "."</font></td>"; 
										}
										else
										{
											echo "<td width='50' align = center>".$n->Age."</td>";
										}
										if ($n->Birthday == 0  || $n->Birthday == null)
										{
											echo "<td width='50' align = center>"." - "."</td>"; 
										}
										else
										{
											echo "<td width='50' align = center>".$n->Birthday."</td>";
										}
										if ($n->Sex == 0  || $n->Sex == null)
										{
											echo "<td width='50' align = center>"." - "."</td>"; 
										}
										else
										{
											echo "<td width='50' align = center>".$n->Sex."</td>";
										}
										
										echo "</tr>";
									}
							
													echo "<tr></tr><tr></tr>";
													echo "</table></center><br>";
													
													echo 	" <br>";
												}
												
										}
										
										else
										{
											echo "<center>No Record Found.</center>";
										}
					}
					
					else
										{
											echo "<center>No Record Found.</center>";
										}
										
?>

goodLuck!

0

@ above member(sorry i can't copy paste the first character of your name here):

what is the meaning of this part of the code??

.$n->Name

thanks sir!

0

@ above member(sorry i can't copy paste the first character of your name here):

what is the meaning of this part of the code??

.$n->Name

thanks sir!

no problem with the name. ;)

this code

.$n->Name

meant :

$n - is from the "while($n=mysql_fetch_object($myquery))" query
-> - is the pointer
Name - is the value from the column name Name of the query itself

i hope you get it. :)

and ooopps!
it's ma'am or miss not sir. :$

0

whew, now i get it..

thanks again ma'am...

no problem detweiller. :icon_wink:
is this thread already solved?

0

not yet already.. im doing some revisions on the codes. i'll post it here if the codes is 100% working so anyone can use the codes.

thanks again..

btw, what im really doing is not abour people but rather printers. i just use people as an example so that i can learn the codes well. cause if i use printer already i will be reallying mostly on your codes and not using my skills in solving the problem..

again thanks ma'am and sir PMC!!

0

Don't bother of Ajax Code with pure JS.
There are a lot of libraries out there that simplify JS.
So Unless you are learning JS, pick one and use the simplified AJAX calls.
My favo is JQuery

0

not yet already.. im doing some revisions on the codes. i'll post it here if the codes is 100% working so anyone can use the codes.

thanks again..

btw, what im really doing is not abour people but rather printers. i just use people as an example so that i can learn the codes well. cause if i use printer already i will be reallying mostly on your codes and not using my skills in solving the problem..

again thanks ma'am and sir PMC!!

no problem.
just post your concerns here. :D

0

got another problem here. here is my complete code

<html>
<head>
<title></title>
</head>
<body>
<!-- select field and query -->
<form method="post" action="index.php">	
<br>
<select name="thePrinter" width = "200">
<option value=''> Printer  </option>
											
<!-- names display -->
<?php
	
	$hostname = "localhost";

	$database = "printer";	

	$username = "root";

	$password = "qwertyui";

	mysql_connect($hostname,$username,$password);

	mysql_select_db($database) or die("Unable to select database");			
	$myquery=mysql_query("SELECT * from printer");
	if(mysql_fetch_object($myquery) == null)
		{
		echo "<option value=''> No Record Found. </option>";
		}
	else
		{	
		$myquery=mysql_query("SELECT * from printer");	
		while($printer=mysql_fetch_object($myquery))
			{
			echo "<option value='$printer->printer'>".$printer->printer."</option>";
			}
		} 
													
?>
											
</select>
<input type="submit" name="view" value="  View  ">
</form>
								
<?php


		$myquery=mysql_query("SELECT * from printer where printer = '$printer'") or die(mysql_error());
		while($n=mysql_fetch_object($myquery))
		{
		<center>
		<font color = 'red'>Printer : </font>.$printer->printer
		}
 		<br>

		<table class = sample align=center width=1350px height = 50>
		<tr bgcolor = '#82CAFA'>
		<td width='50' align = 'center'>Printer Model</center></td>
		<td width='50'><center>Part Number</center></td> 
		<td width='50'><center>Cartridge Number</center></td>
		<td width='100'><center>Description</center></td>
		<td width='50'><center>SRP</center></td>
		</tr><tr></tr>
															
		$myquery=mysql_query("SELECT  printer, partnumber, cartridgenumber, description, srp from printer where printer like '$printer' order by partnumber");
		$n=mysql_fetch_object($myquery))
				{
				$check++;
				}
		</table></center>
										
?>
</body>
</html>

but the output looks like this..
is there any problem with the code??
im using linux ubuntu 10.04 and apache2 for php and phpmyadmin for mysql.
http://i318.photobucket.com/albums/mm422/proemialgods/view.jpg

0

got another problem here. here is my complete code

<html>
<head>
<title></title>
</head>
<body>
<!-- select field and query -->
<form method="post" action="index.php">	
<br>
<select name="thePrinter" width = "200">
<option value=''> Printer  </option>
											
<!-- names display -->
<?php
	
	$hostname = "localhost";

	$database = "printer";	

	$username = "root";

	$password = "qwertyui";

	mysql_connect($hostname,$username,$password);

	mysql_select_db($database) or die("Unable to select database");			
	$myquery=mysql_query("SELECT * from printer");
	if(mysql_fetch_object($myquery) == null)
		{
		echo "<option value=''> No Record Found. </option>";
		}
	else
		{	
		$myquery=mysql_query("SELECT * from printer");	
		while($printer=mysql_fetch_object($myquery))
			{
			echo "<option value='$printer->printer'>".$printer->printer."</option>";
			}
		} 
													
?>
											
</select>
<input type="submit" name="view" value="  View  ">
</form>
								
<?php


		$myquery=mysql_query("SELECT * from printer where printer = '$printer'") or die(mysql_error());
		while($n=mysql_fetch_object($myquery))
		{
		<center>
		<font color = 'red'>Printer : </font>.$printer->printer
		}
 		<br>

		<table class = sample align=center width=1350px height = 50>
		<tr bgcolor = '#82CAFA'>
		<td width='50' align = 'center'>Printer Model</center></td>
		<td width='50'><center>Part Number</center></td> 
		<td width='50'><center>Cartridge Number</center></td>
		<td width='100'><center>Description</center></td>
		<td width='50'><center>SRP</center></td>
		</tr><tr></tr>
															
		$myquery=mysql_query("SELECT  printer, partnumber, cartridgenumber, description, srp from printer where printer like '$printer' order by partnumber");
		$n=mysql_fetch_object($myquery))
				{
				$check++;
				}
		</table></center>
										
?>
</body>
</html>

but the output looks like this..
is there any problem with the code??
im using linux ubuntu 10.04 and apache2 for php and phpmyadmin for mysql.
http://i318.photobucket.com/albums/mm422/proemialgods/view.jpg

i won't be able to view the image in the link due to restricted access here in my unit.
can you please tell me what the error said?

thanks. Ϋ

0

the error is in the here

Printer : .$printer->printer }
$myquery=mysql_query("SELECT printer, partnumber, cartridgenumber, description, srp from printer where printer like '$printer' order by partnumber"); $n=mysql_fetch_object($myquery)) { $check++; }

it is visible in the browser as text. that should not happen, right??

0

the error is in the here

Printer : .$printer->printer }
$myquery=mysql_query("SELECT printer, partnumber, cartridgenumber, description, srp from printer where printer like '$printer' order by partnumber"); $n=mysql_fetch_object($myquery)) { $check++; }

it is visible in the browser as text. that should not happen, right??

sorry for taking long.
I've decided to make the same table in my database like your printer table
just for debugging . Ϋ

here's i got.

- missing "echo" syntax
- additional queries
- i have here the codes already done

<?php 
//require('connect.php'); 
//this is for my connection to database - for my sample only
?>

<html>
<head>
<title></title>
</head>
<body>

<!-- select field and query -->
<form method="post">	
<!-- i temporary removed the action = "index.php" -->
<br>
<select name="thePrinter" width = "200">
<option value=''> Printer  </option>
											
<!-- names display -->

<?php
	
	$hostname = "localhost";
	$database = "printer";	
	$username = "root";
	$password = "qwertyui";

	mysql_connect($hostname,$username,$password);
	mysql_select_db($database) or die("Unable to select database");			
	
	$myquery=mysql_query("SELECT distinct printer from printer");
	// * to printer - printer model for selection option
	// do use distinct for no duplication
	
	if(mysql_fetch_object($myquery) == null)
		{
			echo "<option value=''> No Record Found. </option>";
		}
		
	else
		{	
			$myquery=mysql_query("SELECT distinct printer from printer");	
			//* to printer and distinct
			while($printer=mysql_fetch_object($myquery))
			{
				echo "<option value='$printer->printer'>".$printer->printer."</option>";
			}
		} 
													
?>
											
</select>
<input type="submit" name="view" value="  View  ">
</form>
								
<?php

if ($_POST['view'])
{
	
	$printer = $_POST['thePrinter']; 
	//initialize for the '$printer' variable
	// from the select field select name = "thePrinter" from the top

	if($printer == null)
	{
		echo "<script type='text/javascript'>window.alert('Please check your inputs.')</script>";
		echo "<META http-equiv='refresh' content='0; URL=n.php'>";
		//you may change the n.php to index.php
	}
	// for null value or for no selection

	else if($printer != null)
	{
		$myquery=mysql_query("SELECT  * from printer");
						
		if(mysql_fetch_object($myquery) == null)
		{
			echo "<center>No Record Found.</center>";
		}
		// check for if empty table or database
												
		else
		{
			$myquery=mysql_query("SELECT * from printer where printer like '$printer'") or die(mysql_error());  
			// = to like
			
			while($n=mysql_fetch_object($myquery))
			{
				echo"<center>
				<font color = 'red'>Printer : </font>".$n->printer;
				//$printer to $n
			}
			
			echo"
			<br>
			<table class = sample align=center width=1350px height = 50>
			<tr bgcolor = '#82CAFA'>
			<td width='50' align = 'center'>Printer Model</center></td>
			<td width='50'><center>Part Number</center></td> 
			<td width='50'><center>Cartridge Number</center></td>
			<td width='100'><center>Description</center></td>
			<td width='50'><center>SRP</center></td>
			</tr><tr></tr> ";

			$myquery=mysql_query("SELECT  printer, partnumber, cartridgenumber, description, srp 
				from printer where printer like '$printer' 
				order by partnumber");
			
			$check = 0;
			//initialize $check
			
			while($n=mysql_fetch_object($myquery))
			// while statement again here for query display
			{
				$check++;
					
					echo "<tr>";
					echo "<td align = center>".$n->printer."</td>";
					echo "<td align = center>".$n->partnumber."</td>";
					echo "<td align = center>".$n->cartridgenumber."</td>";
					echo "<td align = center>".$n->description."</td>";
					echo "<td align = center>".$n->srp."</td>";
					echo "</tr>";
					
					//display query for each column
			}
			echo "<tr></tr></table></center>";
		}

	}

	else
	{
		echo "<center>No Record Found.</center>";
	}

}	

else
{
	echo "   -   ";
}

?>
</body>
</html>

- just change the n.php to the name of your file like index.php

:)i hope this helps.
good luck!
happy day! Ϋ

0

until now i don't know what the heck is the problem because it displays the same kind of problem.
is there as way that the we will not use the "echo" code since the problem starts everytime there is an echo string in the codes.

im not sure if there is also a problem with my system..

sorry for the burden..

0

until now i don't know what the heck is the problem because it displays the same kind of problem.
is there as way that the we will not use the "echo" code since the problem starts everytime there is an echo string in the codes.

I'm not sure if there is also a problem with my system..

sorry for the burden..

weird. i have tested it myself.
the problem, most probably is within the database connection part.
hhhhmmmm.

do you want to try to separate the codes for database connection to another page?

0

if it will solve the problem then its ok with me..

try it with this :

-- index.php --

<?php 
require('connect.php'); 
//this is for my connection to database - for my sample only
?>

<html>
<head>
<title></title>
</head>
<body>

<!-- select field and query -->
<form method="post">	
<!-- i temporary removed the action = "index.php" -->
<br>
<select name="thePrinter" width = "200">
<option value=''> Printer  </option>
											
<!-- names display -->

<?php
	
	//$hostname = "localhost";
	//$database = "printer";	
	//$username = "root";
	//$password = "qwertyui";

	//mysql_connect($hostname,$username,$password);
	//mysql_select_db($database) or die("Unable to select database");	
        . . .

	
-- connect.php --

<?php

	mysql_connect("localhost", "root", "qwertyui");
	mysql_select_db("printer");
	
	//date_default_timezone_set('UTC + 8');

?>

extra check also your connection strings.
the whole code works with me.

just comment out some line and create a connect.php in the same directory of your index.php.
i hope it'll work now. :'(

good luck! (crossed-fingers) Ϋ

0

hmmm.. i got a hunch now where the real problem is, and it hurts to admit it if it does.

i'll tell you the error tomorrow if im 100% then..
till tomorrow Ms. Kim E.

thanks!!

0

I know I'm kinda late to the party here, but if you prefer not to use JS (I'd use a library then like @ev said) here's the basic structure of populating a list with PHP and then returning results for that list:

<?php
//Connect to MySQL & Select DB
mysql_connect($host, $user, $pass) or die('There was an error with the database server. Please try again later.');
mysql_select_db($db) or die('There was an error with the database. Please try again later.');
?>
<!docytype html>
<html>
<head>
<title>PHP Popluate & Return Demo</title>
</head>
<body>

<form action="<?=$_SERVER['PHP_SELF']?>" method="get">

<?php $result = mysql_query("SELECT id, name FROM data") or die('Could not retrieve database information. Please try again later.'); ?>
<select name="id">
<?php while($data = mysql_fetch_array($result)): ?>
    <option value="<?=$data['id']?>"><?=$data['name']?></option>
<?php endwhile; ?>
</select>

<input type="Submit" name="action" value="View">
</form>


<?php if($_GET['action'] == 'View'): ?>

<?php if($result = mysql_query() && mysql_num_row($result) > 0): ?>
<table>
<thead>
    <td>ID</td>
    <td>Name</td>
    <td>Field1</td>
    <td>Field2</td>
    <!-- etc. -->
</thead>

<?php while($data = mysql_fetch_array($result)): ?>
<tr>
    <td><?= $data['id'] ?></td>
    <td><?= $data['name'] ?></td>
    <td><?= $data['field1'] ?></td>
    <td><?= $data['field2'] ?></td>
    <!-- etc. -->
</tr>
<?php endwhile; ?>

</table>
<?php else: ?>
<p>No results could be found for the given id</p>
<?php endif ?>

<?php endif; ?>
</body>
</html>

Edited by FlashCreations: n/a

0

I know I'm kinda late to the party here, but if you prefer not to use JS (I'd use a library then like @ev said) here's the basic structure of populating a list with PHP and then returning results for that list:

<?php
//Connect to MySQL & Select DB
mysql_connect($host, $user, $pass) or die('There was an error with the database server. Please try again later.');
mysql_select_db($db) or die('There was an error with the database. Please try again later.');
?>
<!docytype html>
<html>
<head>
<title>PHP Popluate & Return Demo</title>
</head>
<body>

<form action="<?=$_SERVER['PHP_SELF']?>" method="get">

<?php $result = mysql_query("SELECT id, name FROM data") or die('Could not retrieve database information. Please try again later.'); ?>
<select name="id">
<?php while($data = mysql_fetch_array($result)): ?>
    <option value="<?=$data['id']?>"><?=$data['name']?></option>
<?php endwhile; ?>
</select>

<input type="Submit" name="action" value="View">
</form>


<?php if($_GET['action'] == 'View'): ?>

<?php if($result = mysql_query() && mysql_num_row($result) > 0): ?>
<table>
<thead>
    <td>ID</td>
    <td>Name</td>
    <td>Field1</td>
    <td>Field2</td>
    <!-- etc. -->
</thead>

<?php while($data = mysql_fetch_array($result)): ?>
<tr>
    <td><?= $data['id'] ?></td>
    <td><?= $data['name'] ?></td>
    <td><?= $data['field1'] ?></td>
    <td><?= $data['field2'] ?></td>
    <!-- etc. -->
</tr>
<?php endwhile; ?>

</table>
<?php else: ?>
<p>No results could be found for the given id</p>
<?php endif ?>

<?php endif; ?>
</body>
</html>

nice codes PMC.
Ϋ

0

what does this mean:

action="<?=$_SERVER?>"

and this:

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

0

sorry for taking long.
I've decided to make the same table in my database like your printer table
just for debugging . Ϋ

here's i got.

- missing "echo" syntax
- additional queries
- i have here the codes already done

<?php 
//require('connect.php'); 
//this is for my connection to database - for my sample only
?>

<html>
<head>
<title></title>
</head>
<body>

<!-- select field and query -->
<form method="post">	
<!-- i temporary removed the action = "index.php" -->
<br>
<select name="thePrinter" width = "200">
<option value=''> Printer  </option>
											
<!-- names display -->

<?php
	
	$hostname = "localhost";
	$database = "printer";	
	$username = "root";
	$password = "qwertyui";

	mysql_connect($hostname,$username,$password);
	mysql_select_db($database) or die("Unable to select database");			
	
	$myquery=mysql_query("SELECT distinct printer from printer");
	// * to printer - printer model for selection option
	// do use distinct for no duplication
	
	if(mysql_fetch_object($myquery) == null)
		{
			echo "<option value=''> No Record Found. </option>";
		}
		
	else
		{	
			$myquery=mysql_query("SELECT distinct printer from printer");	
			//* to printer and distinct
			while($printer=mysql_fetch_object($myquery))
			{
				echo "<option value='$printer->printer'>".$printer->printer."</option>";
			}
		} 
													
?>
											
</select>
<input type="submit" name="view" value="  View  ">
</form>
								
<?php

if ($_POST['view'])
{
	
	$printer = $_POST['thePrinter']; 
	//initialize for the '$printer' variable
	// from the select field select name = "thePrinter" from the top

	if($printer == null)
	{
		echo "<script type='text/javascript'>window.alert('Please check your inputs.')</script>";
		echo "<META http-equiv='refresh' content='0; URL=n.php'>";
		//you may change the n.php to index.php
	}
	// for null value or for no selection

	else if($printer != null)
	{
		$myquery=mysql_query("SELECT  * from printer");
						
		if(mysql_fetch_object($myquery) == null)
		{
			echo "<center>No Record Found.</center>";
		}
		// check for if empty table or database
												
		else
		{
			$myquery=mysql_query("SELECT * from printer where printer like '$printer'") or die(mysql_error());  
			// = to like
			
			while($n=mysql_fetch_object($myquery))
			{
				echo"<center>
				<font color = 'red'>Printer : </font>".$n->printer;
				//$printer to $n
			}
			
			echo"
			<br>
			<table class = sample align=center width=1350px height = 50>
			<tr bgcolor = '#82CAFA'>
			<td width='50' align = 'center'>Printer Model</center></td>
			<td width='50'><center>Part Number</center></td> 
			<td width='50'><center>Cartridge Number</center></td>
			<td width='100'><center>Description</center></td>
			<td width='50'><center>SRP</center></td>
			</tr><tr></tr> ";

			$myquery=mysql_query("SELECT  printer, partnumber, cartridgenumber, description, srp 
				from printer where printer like '$printer' 
				order by partnumber");
			
			$check = 0;
			//initialize $check
			
			while($n=mysql_fetch_object($myquery))
			// while statement again here for query display
			{
				$check++;
					
					echo "<tr>";
					echo "<td align = center>".$n->printer."</td>";
					echo "<td align = center>".$n->partnumber."</td>";
					echo "<td align = center>".$n->cartridgenumber."</td>";
					echo "<td align = center>".$n->description."</td>";
					echo "<td align = center>".$n->srp."</td>";
					echo "</tr>";
					
					//display query for each column
			}
			echo "<tr></tr></table></center>";
		}

	}

	else
	{
		echo "<center>No Record Found.</center>";
	}

}	

else
{
	echo "   -   ";
}

?>
</body>
</html>

- just change the n.php to the name of your file like index.php

:)i hope this helps.
good luck!
happy day! Ϋ

i knew that somehow there's a big problem but not with the code.
i hate to admit it but the big error i'm talking about is USER ERROR.
there's a problem on how i install the programs in my unit.. hahahah

thanks so much Ms. Kim

i just realize yesterday that the person that will help me solve my problem is not just from the same country as mine but from the same region as well

MAURAG TALAGA ANG MGA BICOLANO!!
DIOS MABALOS KIM!!

0

i knew that somehow there's a big problem but not with the code.
i hate to admit it but the big error i'm talking about is USER ERROR.
there's a problem on how i install the programs in my unit.. hahahah

thanks so much Ms. Kim

i just realize yesterday that the person that will help me solve my problem is not just from the same country as mine but from the same region as well

MAURAG TALAGA ANG MGA BICOLANO!!
DIOS MABALOS KIM!!

no problem with that. Ϋ

it's your privilege to mark this thread as solved.
:)happy day ahead!

0

one last thing regarding this thread..

is there a way that the dropdown list menu will be categorized?

my printer list should be categorized by its type (inkjet, color, ribbon, etc.)
is there a way we can do that?? will i use a single data or multiple tables depending on the number of the category in my database??

thanks in advance

0

one last thing regarding this thread..

is there a way that the dropdown list menu will be categorized?

my printer list should be categorized by its type (inkjet, color, ribbon, etc.)
is there a way we can do that?? will i use a single data or multiple tables depending on the number of the category in my database??

thanks in advance

mind to explain further about the expected manipulation?

0

this will be an example drop down menu should look like

---Select a Printer--- [V]
-Inkjet Printer-
s2134
we462
-Color Printer-
b52
f15
-Ribbon Printer-
xx34
d34fs

[V] = the arrow key found in the dropdown list
-Inkjet Printer- = one of the categories, but it can never be selected
s2134 = printer name in the inkjet category, can be selected..

0

this will be an example drop down menu should look like

---Select a Printer--- [V]
-Inkjet Printer-
s2134
we462
-Color Printer-
b52
f15
-Ribbon Printer-
xx34
d34fs

[V] = the arrow key found in the dropdown list
-Inkjet Printer- = one of the categories, but it can never be selected
s2134 = printer name in the inkjet category, can be selected..

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.

Edited by ﻼim: grammar. Ϋ

0

what does this mean:

action="<?=$_SERVER?>"

and this:

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

<?=$_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 :)

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.