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
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?

Link to comment
Share on other sites

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?

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.