Jump to content

same querie, or a new one??


Gem

Recommended Posts

Hi guys,

 

I'm still working on this drop down list.  I've got the actual drop down list to work (call all the "pname"s from the table, and I've even found how to print the result once you press submit.... However...

 

What I need for this to do is once pname has been selected and submitted, I want the information linked to the pname in other tables to also display...

 

SO the question is: Do i add the other information I need into the original query, or will it be easier to do another one?? And if the latter, how and where??

 

Thanks

 

Gem

 

<?php 

$conn = mysql_connect("CNX") or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('bssql',$conn) or trigger_error("SQL", E_USER_ERROR);

$sql="SELECT pname FROM pname ORDER BY pname"; 
$result=mysql_query($sql); 

$options=""; 

while ($row=mysql_fetch_array($result)) { 

    $id=$row["pname"]; 
    $thing=$row["pname"]; 
    $options.="<OPTION VALUE=\"$id\">".$thing.'</option>'; 
} 


?> 


<html>
<body>

<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<SELECT NAME=pname> 
<OPTION VALUE=0>Choose 
<?=$options?> 
</SELECT> 
<input type="submit" name="submit" value="submit">
</FORM>

<?php

if(isset($_GET['submit'])){
print stripslashes($_GET['pname']);

} 
?>

Link to comment
https://forums.phpfreaks.com/topic/182547-same-querie-or-a-new-one/
Share on other sites

I do not realy understand your question, am I correct when I assume that:

 

You have a dropdown list and when you select an item there and press submit you want to display the data related to the selected item?

 

If so (and in fact in general) you make a new query and add a WHERE clause. I do not know the structure of your database, so I'm afraid I can't help you any further until you provide extra information.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.