Jump to content

php sorting with html


astani

Recommended Posts

Hi,

 

I am a php newbe I have a Posgresql db and am trying to do a sort routine based on project titles or project owners. I have an html dropdown for this. I have an array that displays the letters of the alphabet and would like to be able to pick from the dropdown and populate the names of projects alphabetically or names of projects by creator.

Here is what I have so far, the queries don't seem to work or maybe just not displaying, any help would be apreciated.

 

<h4 align="left">Sort By: </h4>

<form name="jump">

<p align="left">

<select name="menu">

<option value="URL"> Project Name</option>

<option value="URL"> Owner</option>

</select>

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

$projByTitle = pg_fetch_array($sort_query);

$sort_query1 = pg_query("SELECT * FROM users ORDER BY username");

$projByOwner = pg_fetch_array($sort_query1);

?>

<input type="button" name="<?php if (jump.menu.selectedIndex == "0") { echo "$projByTitle"; } else { echo "$projByOwner"; } ?> " method = "post" value="GO">

 

Thanks,

Andy

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.