Jump to content

Help with displaying selected dropdown menu on another page with related queries


maxves1

Recommended Posts

Hello ,

Can anyone help me with displaying results of my php onto another page?

Heres the code I wrote for search category and it works fine :

<?php

 

include ('db_connect.php');  // DATABASE CONNECTION

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>

<head>

<META http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta http-equiv="refresh" content="180; url=http://faculty.poly.edu/~yjeanpie/searchcat.php">

 

<SCRIPT language=JavaScript>

function reload(form)

{

var val=form.cat.options[form.cat.options.selectedIndex].value;

self.location='searchcat.php?cat=' + val ;

 

}

 

</script>

<script Language="JavaScript">

<!--

function confirm_dropdown()

{

 

if (f1.cat.options.selectedIndex == 0)

{

 

alert("Please select the Category.");

 

f1.cat.focus();

return (false);

}

 

if (f1.subcat.options.selectedIndex == 0)

{

 

alert("Please select the Products.");

 

f1.subcat.focus();

return (false);

}

return (true);

}

//--></script>

<script language=" JavaScript" ><!--

function MyReload()

{

window.location.reload();

}

//--></script>

 

</head>

<body onLoad=" MyReload()">

 

<center>

  <p> </p>

    <p> </p>

        <p> </p>

<div><center>

 

 

<hr align="center" size="1" width="550" color="#99CCFF">

  <hr align="center" size="1" width="550" color="#99CCFF">

  <p><img src="fitl reslogo.jpg" width="223" height="67"></p>

  <p><font face="Arial, Helvetica, sans-serif" size="2" align="Left">Search by Category</font></p>

 

 

<div align="center">

<?

 

 

@$cat=$_GET['cat'];

if(strlen($cat) > 0 and !is_numeric($cat)){

echo "Data Error";

exit;

}

 

$quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category");

 

if(isset($cat) and strlen($cat) > 0){

$quer=mysql_query("SELECT DISTINCT prod_name FROM PRODUCTS where cat_id=$cat order by prod_name");

}

 

echo '<form method=post name=f1 action="dd-check1.php" onsubmit="return confirm_dropdown()">';

 

echo "<select name='cat' onchange=\"reload(this.form)\"><option value='' style= width:13em;>Select category</option>";

while($noticia2 = mysql_fetch_array($quer2)) {

if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";}

else{echo  "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";}

}

echo "</select>";

echo "<br>";

echo "<br>";

echo "<select name='subcat' style= width:15em;><option value=''>Select products</option>";

while($noticia = mysql_fetch_array($quer)) {

echo  "<option value='$noticia[prod_name]'>$noticia[prod_name]</option>";

 

}

echo "</select>";

echo "<br>";

echo "<br>";

 

echo '<input type=image src="back.jpg" srcname=btnback id=btnback  onclick="history.go(-1);return false;"/>';

echo '<span style="padding-left:10px">';

echo '<input type=image src="button.JPG" >';

 

echo '</span>';

 

echo "</form>";

?>

 

 

</div></center>

  <br>

  <hr align="center" size="1" width="550" color="#99CCFF">

  <hr align="center" size="1" width="550" color="#99CCFF">

</div></center>

 

</div> </center>

</body></html>

 

Now I saved this file onto my database as searchcat.php

you can check the link at:

http://faculty.poly.edu/~yjeanpie/searchcat.php

 

only problem is upon submission ,I want it to display results onto a new page "dd-check1" in this case, in such a way, that it displays the category and product selected and along with it, it displays relevant information related with the specific product for the category selected,

like say for example

"if i select software and photoshop "

I want it to show that on the other page along with the tutorial links i have in database and other relevant info "

My databse PRODUCTS looks like the file attached ( from where i want to retrieve other relevant results"

PLEASE HELP ME ASAP , i need to get this done within 2 weeks :(

any help will be honestly appreciated

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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