karol65 Posted May 22, 2008 Share Posted May 22, 2008 Hi, I am completely newbie. I have created dropdown list, that reads some vars form msql Dbase. The thing is I would like to allow, by clicking on selected position form dropdown, to display all rows (form ID) in new or new window. my code: <?php $query = mysql_query("SELECT * FROM table ORDER BY id"); echo '<select name="ids" style="width :500px">'; while($row = mysql_fetch_array($query)) { echo '<option name="'.$row['id'].'">'.$row['name'].', CMD: '.$row['cmd'].', Date: '.$row['StartDate'].'</option>'; } echo '</select>'; ?> I don't know how to pass those vars (or how to declare it). Thanks for any suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/106799-solved-phpmysql-dropdown-select-id-and-display-its-row-in-div-or-new-page/ Share on other sites More sharing options...
MadTechie Posted May 22, 2008 Share Posted May 22, 2008 your list is probably in a form, read here Quote Link to comment https://forums.phpfreaks.com/topic/106799-solved-phpmysql-dropdown-select-id-and-display-its-row-in-div-or-new-page/#findComment-547553 Share on other sites More sharing options...
karol65 Posted May 23, 2008 Author Share Posted May 23, 2008 OK, thanks for reply. I get the point, but I cannot input select list with all records in one place. Instead of this I have (based on script below): |------------||--------------||--------------||------------------| (numbers of those fields = numbers of IDs in table) And how to pass those vars by submit button? <?php include 'config.php'; ?> <?php $sql = "SELECT name,StartDate,id FROM `my_table` ORDER BY `id` ASC"; $result = mysql_query($sql) or die (mysql_error()); echo "<select name=\"\" id=\"\">"; while ($row = mysql_fetch_array($result)){ extract ($row); echo "<form action=\"sum.php\" method=\"post\">"; echo "<select name=\"genfile\" OnChange=\"submit();\">"; echo "<option>-------</option>"; echo "<option value=\"$id\">$name - $cmd - $StartDate</option>"; }//Ends while //echo "</select>"; echo "<input type=\"submit\">"; echo "</form>"; echo "<br />"; echo "<br />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/106799-solved-phpmysql-dropdown-select-id-and-display-its-row-in-div-or-new-page/#findComment-547947 Share on other sites More sharing options...
karol65 Posted May 23, 2008 Author Share Posted May 23, 2008 Now I have something like this: <?php $sql = "SELECT * FROM `table` ORDER BY `id` ASC"; $result = mysql_query($sql) or die (mysql_error()); //echo "<select name=\"\" id=\"\">"; while ($row = mysql_fetch_array($result)){ extract ($row); echo "<form action=\"sum.php\" method=\"post\">"; // echo "<select name=\"genfile\" value=\"$id\" OnChange=\"submit();\">"; echo "<option value=\"$id\" OnChange=\"submit();\" > $name - $cmd - $StartDate - $t_letter_code_ef </option>"; // echo "<value=\"$row[id]\"> $row[t_letter_code_ef]</option>"; //echo "<option value=\"$id\">$name - $cmd - $StartDate</option>"; }//Ends while //echo "</select>"; echo "<br />"; echo "<br />"; echo "<input type=\"submit\">"; echo "</form>"; echo "<br />"; echo "<br />"; ?> But this is not a select list, it displays all as a static list, I want to make it clickable, like real select list (dropdonw= and send all row to sum.php. Any idea how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/106799-solved-phpmysql-dropdown-select-id-and-display-its-row-in-div-or-new-page/#findComment-547979 Share on other sites More sharing options...
MadTechie Posted May 28, 2008 Share Posted May 28, 2008 untested <?php if(isset($_POST['Test'])) { echo $_POST['Test']."SELETED<br>"; } $sql = "SELECT * FROM `table` ORDER BY `id` ASC"; $result = mysql_query($sql) or die (mysql_error()); //echo "<select name=\"\" id=\"\">"; echo "<form action=\"sum.php\" method=\"post\">"; echo "<select name=\"Test\">"; //ADDED while ($row = mysql_fetch_array($result)){ extract ($row); echo "<option value=\"$id\" OnChange=\"submit();\" > $name - $cmd - $StartDate - $t_letter_code_ef </option>"; }//Ends while echo "</select>"; echo "<br>"; echo "<br>"; echo "<input type=\"submit\">"; echo "</form>"; echo "<br>"; echo "<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/106799-solved-phpmysql-dropdown-select-id-and-display-its-row-in-div-or-new-page/#findComment-551483 Share on other sites More sharing options...
karol65 Posted October 27, 2008 Author Share Posted October 27, 2008 Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/106799-solved-phpmysql-dropdown-select-id-and-display-its-row-in-div-or-new-page/#findComment-675470 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.