Jump to content

send keywords to search request


mmoalem

Recommended Posts

hi there - first attempt at programming in PHP so please bear with my novice attempts (not much programming experience in any languege really)

i am building a site which hosts mp3s. I have MySQL database with one of the fields contating descriptive keywords for the tracks (such as slow, chilled, intense etc)

i have created an html page with search form that send data to php file which runs a query of the keywords field - and all works fine

 

now i want that in addition to the search form (with an input text box for the search criteria and the submit button) i will have a 'cloud' of key words - clickable links - that will send the data to the PHP query file (clicking on slow will search for tracks described with 'slow' and so on) - any ideas how do send data by clicking on a link?

 

my html form is:

 

<body bgcolor="white">
<form action="test3.php" target="main" method="post">

<input type="text" name="searchkeywords" size=100><br>
<input type="submit" value="Search">
<input name="searchkeywords" value="slow" type="submit">



</form>

<DIV align="center" style="left : 240px; position : absolute; top : 100px;"><iframe src ="test3.php" width="1000" height="800" name="main" frameborder="2" scrolling="no">
  <p>Your browser does not support iframes.</p>
</iframe></DIV>
</body>

 

my php query file is:

<?php
$con = mysql_connect("localhost","root","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("test", $con);

$result = mysql_query("SELECT * FROM music WHERE keywords LIKE '%$_POST[searchkeywords]%'");

$txt1='<A HREF="/audioplayer-standalone/';
$txt2='" ><IMG src="images/misc_23.png" width="32" height="32" align="left" border="0"></A>';
$txt3='<script language="JavaScript" src="/audioplayer-standalone/audio-player.js"></script><object type="application/x-shockwave-flash" data="/audioplayer-standalone/player.swf" id="audioplayer';
$txt4='" height="24" width="290"><param name="movie" value="/audioplayer-standalone/player.swf"><param name="FlashVars" value="playerID=audioplayer';
$txt5='&soundFile=/audioplayer-standalone/';
$txt6='"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent">
</object>';

echo "<table border='1'>
<tr>
<th  width='220' align='left'>Track Name</th>
<th width='220' align='left'>Artist</th>
<th width='220' align='left'>Description</th>
<th></th>
<th></th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['track'] . "</td>";
  echo "<td>" . $row['artist'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $txt1.$row['filename'].$txt2 . "</td>";
echo "<td>" . $txt3.$row['id'].$txt4.$row['id'].$txt5.$row['filename'].$txt6 ."</td>";
  echo "</tr>";
  }
echo "</table>";

// some code

mysql_close($con);
?>

Link to comment
Share on other sites

with a link to send values->>

<a href="somePageName.php?firstRequest=someValue&SecondRequest=someValue"></a>

 

with a form to send values-->

<form name="form1" action="?" method="post">

    	<input name="firstRequest" type="text" value="somevalue" />
        <input name="secondRequest" type="text" value="somevalue" />
        <input type="submit" name="submit" value="send" />

</form>

 

then on the processing (php) page to pick up the values

 


$a = $_REQUEST['firstRequest'];
$b = $_REQUEST['secondRequest'];

 

on your page something like

 

<?php

$result = mysql_query("SELECT * FROM music WHERE keywords LIKE '%".$_POST['searchkeywords']."%' ");
$data = mysql_fetch_array($sql);
foreach ($data as $row)
{
     echo $row['track'];
     echo $row['description'];
     echo $row['keyWord'];
}

?>

Link to comment
Share on other sites

hi there and thank you very much for the reply (sorry for this late response)

however i dont really understand it to be honest (as i said total newbie)

 

the variable name that i use is 'searchkeywords' - this is the word that i use as filter on the mysql query - the form sends that using post method but i dont have a post method to insert into the <a> tag...

 

all i could come up with reading your suggestion is this which doesnt work:

 

<form action="test2.php" target="main" method="post">

<input type="text" name="searchkeywords" size=100><br>
<input type="submit" value="Search">
<input name="searchkeywords" value="slow" type="submit">

</form>
<a  target="main" href="test2.php?searchkeywords=slow">Slow</a>

 

i am not sure why you suggested to change the code on the PHP script as this does what i want it to do fine - the question is how do i post a value to the PHP script using the <a> tag (a href link)

 

any more help on this?

Link to comment
Share on other sites

no worries hope i can explain,

 

I only changed it because i wasn't going to write out your page, I kinda hoped you might get it from the few lines I wrote, any way here goes

 

using a link

 

the link goes to test2.php, ?searchkeywords is the variable that will be picked up on the test2.php page, the value of searchkeywords in this case is jazzMusic.

 

<a href="test2.php?searchkeywords=JazzMusic">search Jazz</a>

 

using a form

 

the submit (button) is normally at the end of the form but its up to you where you put it, in your form you had 2 x submits i would expect you to only need 1, in this case, I have take 1 only leaving the text field and button,

 

using a form you allow the user to specify what they would like to search by, if you pre fill the value i.e slow and it is not over typed by the user, the value of searchkeywords variable will remain slow. 

 

the action tells the form where to send the form data and the method tells how to send it, post sends it behind the scenes (better for lots of data) and post places the data in the url, i.e. if you look at this forums url you will see topic=306775, this is just saying that index.php has been sent the topic var with the value of 306775

 

<form action="test2.php" target="main" method="post">
        <input type="text" name="searchkeywords" size="100" value="slow" /><br>  
        <input type="submit" value="Search">
</form>

 

on the php page (test2.php, I'm guessing you mean in the main frame since you put target = main)

 

<?php

#not writing it all out the above would be db connection info etc....  btw i expext that  '%$_POST[searchkeywords]%'"); will throw an error so have modified it

#$_post['searchkeywords'] is the variable name with a value of what ever you put in the form 

$result = mysql_query("SELECT * FROM music WHERE keywords LIKE '%".$_POST['searchkeywords']."'%' ");

# -->  all your other player code...

#loop through the results
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['track'] . "</td>";
  echo "<td>" . $row['artist'] . "</td>";

  etc, etc ..

echo "</table>";

// some code

mysql_close($con);
?>

 

hope this helps let us know if it doesnt :)

 

 

(also you can only use a form or a link not both at the same time)

Link to comment
Share on other sites

hi again and thanks again!

however this line still doesn't work

<a  target="main" href="test2.php?searchkeywords=slow">Slow</a>

 

i am not sure what it actually doing but the result is the same as sending blank value from the form

 

I am note sure i explained what i was looking for properly - i want to allow the user to search the database by entering a keyword into the form OR by clicking on predetermined keywords... the form on my previously quoted code is for the purpose of allowing the user to define a keyword and the href line to post a value to the php file independently from the form

 

i have now found a kind of a solution by using a hidden form and javascript like this:

 

<form id="myForm1" target="main" action="test2.php" method="post">
<input type="hidden" value="slow" name="searchkeywords"> 
<a href="javascript:document.getElementById('myForm1').submit()">submit direct</a><br>
</form>

 

or like this

<form  target="main" action="test2.php" method="post">
<input type="hidden" value="slow" name="searchkeywords"> 
<input type="image" src="images/misc_23.png">
</form>

 

but i think it has a lot of overhead code wasted writing a hidden form for each value...

 

 

Link to comment
Share on other sites

ok, so on the page that is intended to receive the form data have you  echoed out the post/get data to make sure its not there? I normally just add

 

<?php 
print_r($_REQUEST);
?>

 

somewhere on the page. Are you using frames? maybe the form data is being sent to the wrong page? maybe put the whole page on the forum, you never know there maybe an issue somewhere else.

:)

 

Link to comment
Share on other sites

ok not sure what i am doing wrong - the print request suggest that it posts ok

here are the full code files:

 

test2.php

<?php
print_r($_REQUEST);
$con = mysql_connect("localhost","root","*****");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("test", $con);

$result = mysql_query("SELECT * FROM music WHERE keywords LIKE '%$_POST[searchkeywords]%'");

$txt1='<A HREF="/audioplayer-standalone/';
$txt2='" ><IMG src="images/misc_23.png" width="32" height="32" align="left" border="0"></A>';
$txt3='<script language="JavaScript" src="/audioplayer-standalone/audio-player.js"></script><object type="application/x-shockwave-flash" data="/audioplayer-standalone/player.swf" id="audioplayer';
$txt4='" height="24" width="290"><param name="movie" value="/audioplayer-standalone/player.swf"><param name="FlashVars" value="playerID=audioplayer';
$txt5='&soundFile=/audioplayer-standalone/';
$txt6='"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent">
</object>';

echo "<table border='1'>
<tr>
<th  width='220' align='left'>Track Name</th>
<th width='220' align='left'>Artist</th>
<th width='220' align='left'>Description</th>
<th></th>
<th></th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['track'] . "</td>";
  echo "<td>" . $row['artist'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $txt1.$row['filename'].$txt2 . "</td>";
echo "<td>" . $txt3.$row['id'].$txt4.$row['id'].$txt5.$row['filename'].$txt6 ."</td>";
  echo "</tr>";
  }
echo "</table>";

// some code

mysql_close($con);
?>

 

Search.html

<html>
<head>
<title>search database</title>
</head>
<body bgcolor="white">
<form action="test2.php" target="main" method="post">

<input type="text" name="searchkeywords" size=100><br>
<input type="submit" value="Search">
<input name="searchkeywords" value="slow" type="submit">




</form>
<a  target="main" href="test2.php?searchkeywords=slow">Slow</a>
<form id="slow" target="main" action="test2.php" method="post">
<input type="hidden" value="slow" name="searchkeywords"> 
<a href="javascript:document.getElementById('slow').submit()">search for slow</a><br>
<input type="image" src="images/misc_23.png">
</form>

<DIV align="center" style="left : 240px; position : absolute; top : 100px;"><iframe src ="test2.php" width="1000" height="800" name="main" frameborder="2" scrolling="no">
  <p>Your browser does not support iframes.</p>
</iframe></DIV>
</body>
</html>

Link to comment
Share on other sites

ok so here goes this is not your whole page but it should give the functionality you need (if im understanding what you need), just mod it to include all your database stuff

 

frame.php -->

 

<?php session_start(); 
if(!empty($_REQUEST)){
$_SESSION['searchkeywords'] = $_REQUEST['searchkeywords']; 
}
?>

<style>
body{background:#FFF;}
.mainDiv{left : 240px; position : absolute; top : 100px;}
</style>

<body>

<form action="mp3.php" name="form1" id="form1" target="main" method="post">
    <input type="text" name="searchkeywords" size="100" value=""><br>
    <input type="submit" name="submit" value="Search">
</form>


<div class="mainDiv">
    <iframe src="mp3.php" width="300" height="300" name="main" id="main" frameborder="2" scrolling="no">
      <p>Your browser does not support iframes.</p>
    </iframe>
</div>

<ul>
<li><a href="?searchkeywords=slow">slow</a></li>
<li><a href="?searchkeywords=medium">medium</a></li>
<li><a href="?searchkeywords=fast">fast</a></li>
</ul>
</body>

 

mp3.php -->

 

<?php session_start(); 

	$keyword = NULL;

	if(!empty($_SESSION['searchkeywords']))
	{
	$keyword = $_SESSION['searchkeywords'];
	unset($_SESSION['searchkeywords']);
	}

	if(!empty($_REQUEST['searchkeywords']))
	{
	$keyword = $_REQUEST['searchkeywords'];
	unset($_REQUEST['searchkeywords']);
	}


	$result = "SELECT * FROM music WHERE keywords LIKE '%".$keyword."%' ";
	echo "<p>".$result."</p>";

?>

 

 

at the top there is a form that will allow the user to specify a keyword, under that there are some pre defined key words (a links),

the first thing the page does is look for data in the URL (if its there some one has used a link), it then sets a session var. with the URL data.

 

then the Iframe loads with the mp3 page which either looks for the session var., or any form data that may have been posted to the page and runs (echoes) the query

 

:)

Link to comment
Share on other sites

hi there again - and again thanks for the help

tried to copy the code as you posted into my pages but it still doesnt work - the key words return th complete list of all database entries

 

i think i will stick to hidden foms for now as at least i understand what i am doing and not just coping/pasting - is there any reason not to use hidden forms?

 

i am posting the pages as i have made them with your suggestion - if you see something obvious please comment otherwise i shall stick to the hidden form variation

 

Search.html

 

<ul bgcolor="white">
<?php session_start(); 
if(!empty($_REQUEST)){
$_SESSION['searchkeywords'] = $_REQUEST['searchkeywords']; 
}
?>

<form action="test5.php" target="main" method="post">

<input type="text" name="searchkeywords" size=100><br>
<input type="submit" value="Search">

</form>
<a  target="main" href="test5.php?searchkeywords=slow">Slow</a>
<form id="slow" target="main" action="test5.php" method="post">
<input type="hidden" value="slow" name="searchkeywords"> 
<a href="javascript:document.getElementById('slow').submit()">submit direct</a><br>
<input type="image" src="images/misc_23.png">
</form>
<ul>
<li><a href="?searchkeywords=slow">slow</a></li>
<li><a href="?searchkeywords=medium">medium</a></li>
<li><a href="?searchkeywords=fast">fast</a></li>
</ul>
<DIV align="center" style="left : 240px; position : absolute; top : 100px;"><iframe src ="test5.php" width="1000" height="800" name="main" frameborder="2" scrolling="no">
  <p>Your browser does not support iframes.</p>
</iframe></DIV>
</body>
</html>

 

test5.php

<?php
print_r($_REQUEST);
$con = mysql_connect("localhost","root","*****");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("test", $con);
$keyword = NULL;

	if(!empty($_SESSION['searchkeywords']))
	{
	$keyword = $_SESSION['searchkeywords'];
	unset($_SESSION['searchkeywords']);
	}

	if(!empty($_REQUEST['searchkeywords']))
	{
	$keyword = $_REQUEST['searchkeywords'];
	unset($_REQUEST['searchkeywords']);
	}


$result = mysql_query("SELECT * FROM music WHERE keywords LIKE '%".$keyword."%'");
echo "<p>".$result."</p>";

$txt1='<A HREF="/audioplayer-standalone/';
$txt2='" ><IMG src="images/misc_23.png" width="32" height="32" align="left" border="0"></A>';
$txt3='<script language="JavaScript" src="/audioplayer-standalone/audio-player.js"></script><object type="application/x-shockwave-flash" data="/audioplayer-standalone/player.swf" id="audioplayer';
$txt4='" height="24" width="290"><param name="movie" value="/audioplayer-standalone/player.swf"><param name="FlashVars" value="playerID=audioplayer';
$txt5='&soundFile=/audioplayer-standalone/';
$txt6='"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent">
</object>';

echo "<table border='1'>
<tr>
<th  width='220' align='left'>Track Name</th>
<th width='220' align='left'>Artist</th>
<th width='220' align='left'>Description</th>
<th></th>
<th></th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['track'] . "</td>";
  echo "<td>" . $row['artist'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $txt1.$row['filename'].$txt2 . "</td>";
echo "<td>" . $txt3.$row['id'].$txt4.$row['id'].$txt5.$row['filename'].$txt6 ."</td>";
  echo "</tr>";
  }
echo "</table>";

// some code

mysql_close($con);
?>

 

Link to comment
Share on other sites

you can use what ever you need in a form there is no limit to the amount of hidden fields,

 

if the query is returning everything ins the table either every record matches your query or there is an error with the sql,

 

to be honest I don't really get why your adding

 

<a href="javascript:document.getElementById('slow').submit()">submit direct</a>

 

when in your form all you need is a <input type="submit" value="search"> placed within a form to submit it,

 

using

 

<a href="?searchkeywords=slow">slow</a> in a single link is surely better than writing

 

 

<a href="javascript:document.getElementById('slow').submit()">submit direct</a>

<form name="slow">

<input type="hidden" value="slow">

</form>

 

:)

 

 

Link to comment
Share on other sites

Hey,

 

I re-wrote the above with comments so you may get my thinking a little better

 

frame.php

 

<?php session_start(); 

//if not empty request means that someone has either clicked the form and created there own keyword or clicked a link with a predefined value
if(!empty($_REQUEST)){
//create session var and give it the post/get value
$_SESSION['searchkeywords'] = $_REQUEST['searchkeywords']; // store session data
}
?>

<!-- soem style -->
<style>
body{background:#FFF;}
.mainDiv{left : 240px; position : absolute; top : 100px;}
</style>

<body>

<!-- when clicked the value is placed into the main iframe no refresh of the main page (this one) -->
<form action="mp3.php" name="form1" id="form1" target="main" method="post">
    <input type="text" name="searchkeywords" size="100" value=""><br>
    <input type="submit" name="submit" value="Search">
</form>


<div class="mainDiv">
    <iframe src="mp3.php" width="800" height="800" name="main" id="main" frameborder="2" scrolling="no">
      <p>Your browser does not support iframes.</p>
    </iframe>
</div>

<!-- when clicked these refresh the page making the code at the top work -->
<ul>
    <li><a href="?searchkeywords=slow">slow</a></li>
    <li><a href="?searchkeywords=medium">medium</a></li>
    <li><a href="?searchkeywords=fast">fast</a></li>
</ul>
</body>

 

mp3.php

 

<?php session_start();
//start session to use any session variables that may or maynot have been set have been set 

//this page refreshes when the form is submitted or link is ationed

//searchkeywords variable eitther comes from the form (text input box box) or the link (<a href=)  

//at this point keywords has no value 
$keyword = NULL;

//if not empty were saying that there is a session variable search keywords and it has a value 
if(!empty($_SESSION['searchkeywords']))
{
//keywords takes the value of $_SESSION['searchkeywords'];
$keyword = $_SESSION['searchkeywords'];
//destroy the session variable
unset($_SESSION['searchkeywords']);
}

//same as above $_REQUEST will pick upp on either $_POST or $_GET vars so someone can link 
if(!empty($_REQUEST['searchkeywords']))
{
$keyword = $_REQUEST['searchkeywords'];
unset($_REQUEST['searchkeywords']);
}

##put if statement here 

//select everything from the mjsic table where there fields keywords is like $keyword var
$sql = "SELECT * FROM music WHERE keywords LIKE '%".$keyword."%' ";
echo "<p>".$sql."</p>";

//connect to the database or die	
$con = mysql_connect("localhost","root","") or die('Could not connect: ' . mysql_error());
mysql_select_db("test", $con);

//make result the query of the sql
$result = mysql_query($sql);

//your vars
$txt1='<A HREF="/audioplayer-standalone/';
$txt2='" ><IMG src="images/misc_23.png" width="32" height="32" align="left" border="0"></A>';
$txt3='<script language="JavaScript" src="/audioplayer-standalone/audio-player.js"></script><object type="application/x-shockwave-flash" data="/audioplayer-standalone/player.swf" id="audioplayer';
$txt4='" height="24" width="290"><param name="movie" value="/audioplayer-standalone/player.swf"><param name="FlashVars" value="playerID=audioplayer';
$txt5='&soundFile=/audioplayer-standalone/';
$txt6='"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent">
</object>';

//make the table
echo "<table border='1'>
<tr>
<th  width='220' align='left'>Track Name</th>
<th width='220' align='left'>Artist</th>
<th width='220' align='left'>Description</th>
<th></th>
<th></th>
</tr>";

//loop through the rows
while($row = mysql_fetch_array($result))
  {
echo "<tr>";
echo "<td>" . $row['track'] . "</td>";
echo "<td>" . $row['artist'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $txt1.$row['filename'].$txt2 . "</td>";
echo "<td>" . $txt3.$row['id'].$txt4.$row['id'].$txt5.$row['filename'].$txt6 ."</td>";
echo "</tr>";
  }

//finish off the table
echo "</table>";


//close connection to db
mysql_close($con);

##end if statement here 
?>

 

if you copy and paste it it should work (I just made the db and tested it) if you done want it to run on page load put an if statement where indicated in the code something like

 

if(!empty($keyword)){

  #do stuff code

}

 

(you may need to change the username and/or password)

 

Link to comment
Share on other sites

thank for the patience!

however it still doesnt work

for the avoidence of doubt:

1. the form i have at the moment works - it posts the keyword entered into the box and returns filtered results in the iframe.

2. the javascript line also works - i get the same results as using the form - to this end everything functions properly so assuming the database is ok and the query is frased correctly.

the code you wrote returns no value in the array (i have copied and pasted your php code as is adding only database password to it

here are some screenshots

on page load you get full database list (5 entries in database - Screenshot5.png), on entering 'slow' in the form or pressing the link 'slow' or pressing the link 'search slow' you get one item returned (Screenshot6.png).

pressing the 'slow' (and the other two links as well) from your code returns the full list (Screenshot5.png) - as you can see the text over the table reads: 'SELECT * FROM music WHERE keywords LIKE '%%' - i.e. $keyword has no value

hope this makes sense and thanks again for the patience - i might no be getting very far with this but i learned quite a lot of php coding trying to get it to work

 

[attachment deleted by admin]

Link to comment
Share on other sites

are you saying it does not work because it shows all results on first load?

 

on page load it will show every entry in the table because there is nothing between the %% in the query this is because there is nothing in the Keyword Var.

 

when you click a link or submit the form, the keyword takes a value and filters the results i.e shows the 'slow' values

 

on page load if you don't want it to show any results (you want someone to search first)  add an if statement where I have commented in the code add

 

<?php
#what it does is test if keyword has a value if it does someone has searched
if(!empty($keyword)){
  #do stuff code goes here, the query etc...
}
?>

 

you wrote->>

the code you wrote returns no value in the array (i have copied and pasted your php code as is adding only database password to it

here are some screenshots

 

what array do you mean?

 

let us know how you get on

 

:)

Link to comment
Share on other sites

sorry maybe didnt make myself clear - the page returns all results after clicking your <a> tag links - screenshot5 shows the page for BOTH on load page and after clicking on the links. screenshot6 shows page after clicking the javascript link and using the form to submit a keyword.

in regard to the array - i am enclosing 3 more screenshots - they were taken with the code as i had it on my previous posting - just over the table it states the array value - not an expert but as far as i understand that shows the value of $keyword which is empty when clicking the href links but has a value of 'slow' when clicking the javascript link or using the form

hope this makes a bit more sense...

 

[attachment deleted by admin]

Link to comment
Share on other sites

ok well here we go, here are two pages with forms, links & buttons but no Java script theres no querys, they just show the data moving from one side to the other when the user acts with the page :)

 

frame 1.php

<body bgcolor="white">

<form name"form1" action="test3.php" target="main" method="post">

    <input type="text" name="searchkeywords" id="searchkeywords" size="100" /><br>


    <input name="searchkeywords" value="slow" type="submit">
    <input name="searchkeywords" value="fast" type="submit">
    <input name="searchkeywords" value="medium" type="submit">
    <input name="searchkeywords" value="big" type="submit">
    
    <p><input type="submit"value="Search"></p>
    
</form>

<p><a href="test3.php?searchkeywords=link1" target="main">link1</a>
<p><a href="test3.php?searchkeywords=link2" target="main">link2</a>
<p><a href="test3.php?searchkeywords=link3" target="main">link3</a>
<p><a href="test3.php?searchkeywords=link4" target="main">link4</a>

<div align="center" style="left : 240px; position : absolute; top : 100px;">
<iframe src ="test3.php" width="1000" height="800" name="main" frameborder="2" scrolling="no">
  		<p>Your browser does not support iframes.</p>
  	</iframe>
</div>

</body>

 

test3.php


<style>.data{padding:20px;border:solid 1px #000;margin:20px;}</style>

    <div class="data">
        <p>
            This is the $_GET Data: 
        	<?php print_r($_GET); ?>
        </p>
    </div>
    
    <div class="data">
        <p>
            This is the $_POST Data: 
            <?php print_r($_POST); ?>
        </p>
    </div>
   
    
    <?php
    if(!empty($_GET['searchkeywords']))
{
    ?>
		<p class="data">SELECT * FROM music WHERE keywords LIKE '%".<?php echo $_GET['searchkeywords'];?>."%' </p>
<?php
}
?>
    
    
    <?php
    if(!empty($_POST['searchkeywords']))
{
    ?>
		<p class="data">SELECT * FROM music WHERE keywords LIKE '%".<?php echo $_POST['searchkeywords'];?>."%' </p>
<?php
}
?>
    

    
    

 

Link to comment
Share on other sites

ok things are looking up - tried your pages and as far as i can understand from the results it looks like the issue is GET versus POST - the form is submiting through POST while for the link I need to use the GET method - i'm going to do some reading about the difference between GET and POST as i dont really know much about it... but in short in all previous posts the scripts did not use GET and it is probably why the value did not pass to the querry...

 

 

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.