Jump to content

php sorting with dropdown


astani

Recommended Posts

This code gives me an error on the first line. I am trying to pass in an html option value from the html dropdown box. Help please...

 

if ($_REQUEST['<'OPTION value=.$value.&gt] == "0") {

 

$sort_query = pg_query("SELECT * FROM projects ORDER BY title");

$projByTitle = pg_fetch_array($sort_query);

}

else

{

$sort_query = pg_query("SELECT * FROM projects ORDER BY username");

$projByOwner = pg_fetch_array($sort_query);

}

Link to comment
https://forums.phpfreaks.com/topic/125345-php-sorting-with-dropdown/
Share on other sites

if ($_REQUEST[''] == "0") {

 

That's not a valid name for a request.  Look how many single quotes you have.  You're giving it an HTML option input name.  What are you trying to pass through?  Could you post the code where you're trying to get your values from?

Here is the html code:

<html>

<form>

<select name="Sort" >

<option value="0" selected = "selected">By Name</option>

<option value="1" >By Owner</option>

</select>

 

<form id="sort1" action="sort1.php" method="post" name= "sort">

<input type="hidden" name="id" value="<? echo '<OPTION value='.$value.'> '.$value.'' ?>" />

<input type="submit" id="submit" name="submit" value ="submit"/>

</form>

</html>

 

That's not a valid name for a request.  Look how many single quotes you have.  You're giving it an HTML option input name.  What are you trying to pass through?  Could you post the code where you're trying to get your values from?

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.