Advanced Minds

  • Decrease font size
  • Default font size
  • Increase font size
  • default color
  • red color
  • green color
FireBoard
Welcome, Guest
Please Login or Register.    Lost Password?
php echo list of numbers Getting Records to update when dropdown list is changed (1 viewing) (1) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: php echo list of numbers Getting Records to update when dropdown list is changed
#1667
Ian Davies (Visitor)
Click here to see the profile of this user
Birthdate:
php echo list of numbers Getting Records to update when dropdown list is changed  
Hello In a php file I have a drop down list with index numbers in whos default value is feed into an sql query that filters records from my data_base_ and displays them in an html table. Trouble is this happens as soon as the php is run so bringing up the same records filtered from the default index. Also when I select a new index no from the drop down list is doesnt refilter the records bringing up the ones for the new list. It still shows the old default ones and the dropdown list changes back to the default value. What alterations do I need to make? Some of my code below (Ive taken irrelevent bits out and simplified the SQL Statements to show only the important bits) Also I dont want to display the index no in the dropdown box. I wish to display its accociated de_script_ion and only use the index for filtering. How do I acheive this? <?php $query_NC = SELECT NCIndex, TopicDesc FROM NC WHERE StatusID = 1 ORDER BY TopicDesc ASC ; $NC = mysql_query($query_NC, $conn) or die(mysql_error()); $row_NC = mysql_fetch_assoc($NC); $totalRows_NC = mysql_num_rows($NC); ? <html <head </head <body    </p    <pUse the drop down lists to filter the data_base_:</p    <blockquote      <form name= form2 method= post action= <?php echo $_SERVER['PHP_SELF']?       <p         <select name= select           <?php do { ?           <option value= <?php echo $row_NC['NCIndex']? <?php if (!(strcmp($row_NC['NCIndex'], $row_NC['NCIndex']))) {echo SELECTED ;} ?<?php echo $row_NC['NCIndex']?</option           <?php } while ($row_NC = mysql_fetch_assoc($NC));   $rows = mysql_num_rows($NC);   if($rows 0) {       mysql_data_seek($NC, 0);    $row_NC = mysql_fetch_assoc($NC);   } ?         </select       </p       <p         <input type= submit name= Submit2 value= Submit       </p     </form     <p      <form name= form3 method=post action=        <p          <?php // Request the text of all the Questions $result = mysql_query( SELECT Mystuff FROM MyTables WHERE Questions.TypeID = QuestionType.TypeID AND NCIndex= ' .$row_NC['NCIndex']. ' ORDER BY QuestionNo ); if (!$result) { exit('<pError performing query: ' . mysql_error() . '</p'); } $row = mysql_fetch_assoc($result); extract($row); ?          <input type= submit name= Submit value= Submit        </p        <table width= 983 border= 2 align= left cellpadding= 0 cellspacing= 0         <tr           <td width= 50 <div align= left <span class= _style_2 Select</span</div</td           <td width= 89 <span class= _style_2 Question No </span</td           <td width= 247 <span class= _style_2 Question</span</td           <td width= 118 <span class= _style_2 Type</span</td           <td width= 282 Options</td           <td width= 181 <span class= _style_2 Image</span</td         </tr         <tr           <?php while($row =& mysql_fetch_assoc($result)) {  extract($row); ?         <tr class= <?php echo $class; ?           <td width= 50 rowspan= 5 valign= top             <div align= center               <input type= checkbox name= checkbox[] value= <? echo $QuestionNo?           </div</td           <td width= 89 rowspan= 5 valign= top <?php echo $QuestionNo; ? </td           <td width= 247 rowspan= 5 valign= top <?php echo $Question; ?</td           <td width= 118 rowspan= 5 valign= top <div align= center </div               <?php echo $TypeDesc; ?</td           <td width= 282 valign= top <div align= left </div               <?php echo $Optiona; ?</td                   <tr class= <?php echo $class; ?           <td width= 282 valign= top <?php echo $Optionb; ?</td         </tr         <tr class= <?php echo $class; ?           <td width= 282 valign= top <?php echo $Optionc; ?</td         </tr         <tr class= <?php echo $class; ?           <td width= 282 valign= top <?php echo $Optiond; ?</td         </tr         <tr class= <?php echo $class; ?           <td width= 282 height= 20 valign= top <?php echo $Optione; ?</td         </tr <?php } // end while ?       </table       <p </p       <p </p     </form <p</blockquote </body <html
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1668
HawkEye (Visitor)
Click here to see the profile of this user
Birthdate:
php echo list of numbers Getting Records to update when dropdown list is changed  
Hello In a php file I have a drop down list with index numbers in whos default value is feed into an sql query that filters records from my data_base_ and displays them in an html table. Trouble is this happens as soon as the php is run so bringing up the same records filtered from the default index. Also when I select a new index no from the drop down list is doesnt refilter the records bringing up the ones for the new list. It still shows the old default ones and the dropdown list changes back to the default value. What alterations do I need to make? Some of my code below (Ive taken irrelevent bits out and simplified the SQL Statements to show only the important bits) Also I dont want to display the index no in the dropdown box. I wish to display its accociated de_script_ion and only use the index for filtering. How do I acheive this? <?php $query_NC = SELECT NCIndex, TopicDesc FROM NC WHERE StatusID = 1 ORDER BY TopicDesc ASC ; $NC = mysql_query($query_NC, $conn) or die(mysql_error()); $row_NC = mysql_fetch_assoc($NC); $totalRows_NC = mysql_num_rows($NC); ? <html <head </head <body    </p    <pUse the drop down lists to filter the data_base_:</p    <blockquote      <form name= form2 method= post action= <?php echo $_SERVER['PHP_SELF']?       <p         <select name= select           <?php do { ?           <option value= <?php echo $row_NC['NCIndex']? <?php if (!(strcmp($row_NC['NCIndex'], $row_NC['NCIndex']))) {echo SELECTED ;} ?<?php echo $row_NC['NCIndex']?</option           <?php } while ($row_NC = mysql_fetch_assoc($NC));   $rows = mysql_num_rows($NC);   if($rows 0) {       mysql_data_seek($NC, 0);    $row_NC = mysql_fetch_assoc($NC);   } ?         </select       </p       <p         <input type= submit name= Submit2 value= Submit       </p     </form     <p      <form name= form3 method=post action=        <p          <?php // Request the text of all the Questions $result = mysql_query( SELECT Mystuff FROM MyTables WHERE Questions.TypeID = QuestionType.TypeID AND NCIndex= ' .$row_NC['NCIndex']. ' ORDER BY QuestionNo ); if (!$result) { exit('<pError performing query: ' . mysql_error() . '</p'); } $row = mysql_fetch_assoc($result); extract($row); ?          <input type= submit name= Submit value= Submit        </p        <table width= 983 border= 2 align= left cellpadding= 0 cellspacing= 0         <tr           <td width= 50 <div align= left <span class= _style_2 Select</span</div</td           <td width= 89 <span class= _style_2 Question No </span</td           <td width= 247 <span class= _style_2 Question</span</td           <td width= 118 <span class= _style_2 Type</span</td           <td width= 282 Options</td           <td width= 181 <span class= _style_2 Image</span</td         </tr         <tr           <?php while($row =& mysql_fetch_assoc($result)) {  extract($row); ?         <tr class= <?php echo $class; ?           <td width= 50 rowspan= 5 valign= top             <div align= center               <input type= checkbox name= checkbox[] value= <? echo $QuestionNo?           </div</td           <td width= 89 rowspan= 5 valign= top <?php echo $QuestionNo; ? </td           <td width= 247 rowspan= 5 valign= top <?php echo $Question; ?</td           <td width= 118 rowspan= 5 valign= top <div align= center </div               <?php echo $TypeDesc; ?</td           <td width= 282 valign= top <div align= left </div               <?php echo $Optiona; ?</td                   <tr class= <?php echo $class; ?           <td width= 282 valign= top <?php echo $Optionb; ?</td         </tr         <tr class= <?php echo $class; ?           <td width= 282 valign= top <?php echo $Optionc; ?</td         </tr         <tr class= <?php echo $class; ?           <td width= 282 valign= top <?php echo $Optiond; ?</td         </tr         <tr class= <?php echo $class; ?           <td width= 282 height= 20 valign= top <?php echo $Optione; ?</td         </tr <?php } // end while ?       </table       <p </p       <p </p     </form <p</blockquote </body <html Without putting the code on a php server it's a bit difficult to be certain but I think what you need is an if(isset($select....  Then feed that into your sql query and it should work.  Below is a cut down exmaple from something I did for a friend a while ago. Hopefully it will make it a little clearer what I mean <form method= post action= seasons.php    <table width= 20% border= 0 cellspacing= 0 cellpadding= 0      <tr      <td width= 60% Choose Season</td      <td width= 40% <div align= right                     <select name= season            <option </option            <option value= 1 1</option            <option value= 2 2</option            <option value= 3 3</option          </select                                 </div                 </td    </tr </table <input type= submit value= Go   <input type= reset value= Clear </form <? include ('connect.php'); if(isset($season)) { $sql= SELECT * from sgate WHERE season like '$season' ORDER BY episode ; $result=mysql_query( $sql ); print '<bSeason :- '.$season. </b ; print <div align='center' ; print <table border='1' width='60%' ; while($row=mysql_fetch_array($result))                         {                         print <tr<td .$row[episode]. </td<td .$row[air_date]. </td<td<a href='edit.php?id= .$row[id]. 'Edit</a</td</tr ;                         print <tr<td colspan='2'<b .$row[_title_]. </b</td<td </td</tr ;                         print <tr<td colspan='3'<font size='-1' .$row[synopsis]. </font</td</tr ;                         print <tr<td colspan='3'<hr</td</tr ;                         } } ?
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
905 sprawdz autoryzacje no auth nieautoryzowano nieautoryzowano
commercial diving about couponmountain urban legends dive now