Jump to content

astani

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

astani's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. It works you are the best. I tried it the second way without the onclick.
  2. Thanks I'll give it a try and see what happens.
  3. I tried this code and I get results and the links but I don't get the result on clicking individual links; <?php $alph_array = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","R","T","S","U","V","X","Y","Z" ); foreach($alph_array as $var) { echo "<a href='".$var."'>".$var."</a> "; } for($u = 0; $u < count($alph_array); $u++) { if (($title[0]) == ($alph_array[$u])) { ?> <a name = "<? echo $alph_array[$u];?>" <? $sorted_titles = pg_query("SELECT * FROM projects WHERE title LIKE '$alph_array[$u]'%'");?> onClick =" <? echo (pg_fetch_array($sorted_titles)) ?>"></a><? } } ?>
  4. Thanks again I'll give it a try and see what happens.
  5. Your code works!! Thanks, now if I can just figure out how to display it alphabetized by project titles....
  6. One more thing, how would I make the output get displayed by the letters of the alphabet as links.. I have the array to display the alphabet thus far but I don't know how to proceed: <?php $alph_array = array("A" => "A", "B"=>"B", "C" => "C", "D" =>"D", "E"=>"E","F"=>"F", "G"=>"G", "H"=>"H", "I"=>"I","J"=>"J", "K"=>"K","L"=>"L","M"=>"M","N"=>"N","O"=>"O","P"=>"P","Q"=>"Q","R"=>"R","S"=>"S","T"=>"T","U"=>"U","V"=>"V","W"=>"W","X"=>"X","Y"=>"Y","Z"=>"Z" ); $alph_array; foreach ($alph_array as $value) { print_r("$value \n\n\n");} ?>
  7. I'll give it a try and let you know, thanks.
  8. Still not working the way it should. The only way it works is if I do a query before the if statement which it seems to defeat the purpose. I am using php 4.3.9 on the server. <html> //html dropdown with submit form (button) connects to php page below it: <form action ="" name = "sorting"> <select name ="sorting"> <option value="0" input name="byname" >By Name</option> <option value="1" input name ="byowner">By Owner</option> </select> </form> <form id="sort1" action="sort1.php" method="post" name= "sort"> <input type="hidden" name="id1" value = "sub" /> <input name ="submit1" input type="submit" id="submit" value ="submit"/> </form> </html> <?php //conditional with queries based on dropdown choice by user if($form_input['submit1'] == 0) { $sort_query = pg_query("SELECT * FROM projects ORDER BY title"); } elseif($form_input['submit1'] == 1) { $sort_query = pg_query("SELECT * FROM projects ORDER BY username"); } //looping thru to get the records displayed while (($row = pg_fetch_array($sort_query)) && ($row != "")) { for ($i = 0; $i <= 1; $i++) { echo $row[$i] ?><br> <? ; //echo $row1[$i] //print "<pre>"; var_dump($projByTitle); print "</pre>"; } } ?>
  9. Thanks I will give it a try and let you know how it works.
  10. 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?
  11. 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); }
  12. How do I use an if statement to output different queries once I submit the chosen option? <select name="Sort"> <option value= "Title">By Title</option> <option value="Owner" selected="selected">By Owner</option> </select>
  13. My dropdown works fine I need a way to use an if statement and "selectedindex" in the dropdown to output different queries. Below is code for Dropdown followed by html submit form: //create php dropdown with two sort options $sortBy = array( 1=> "Project Name", 2=> "Owner", ); $category = str_replace(" ", " ", $sortBy); echo '<SELECT name=category>'; foreach ($sortBy as $key => $value) { echo '<OPTION value='.$value.'> '.$value.''; } echo '</select>'; ?> <?php //print "<pre>"; var_dump($projByTitle); print "</pre>"; ?> <!--create html form to execute queries on sort.php on clicking the submit button--> <form id="sort" action="sort1.php" method="post" name= "sort"> <input type="hidden" name="id" value="<? echo "$form_input[title]";?>" /> <input type="submit" id="submit" name="submit" value ="submit"/> <?
  14. My dropdown works fine I need a way to use an if statement and "selectedindex" in the dropdown to output different queries.
  15. I need some help please, how can I make my php dropdown output different results on submit? Is there a selectedindex value and how can I use it? <?php $sortBy = array( 1=> "Project Name", 2=> "Owner", ); $category = str_replace(" ", " ", $sortBy); echo '<SELECT name=category>'; foreach ($sortBy as $key => $value) { echo '<OPTION value='.$value.'> '.$value.''; } echo '</select>'; ?>
×
×
  • 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.