grahamb314 Posted September 14, 2008 Share Posted September 14, 2008 Hi , I have a drop down box which displays show names from an SQL query (Below) I want to further this and allow it to display the shows field and the genre field from the database Any help at all would be fantastic! //index.php <html> <head> <title></title> </head> <body> <p align="center"><strong><img src="Purple_Logo.jpg" width="300" height="113" /></strong> <p align="center"><strong>Delete a Show </strong> </div> <form action="delete_show_results.php" method="POST"> <div align="center"> <p> <select name="toDelete"> <?php require_once 'mysql_connect.php'; $DJshows = mysqli_query($mysqli, "SELECT * FROM shows"); while ($show = mysqli_fetch_assoc($DJshows)) { echo "<option value=\"{$show['show']}\">{$show['show']}</option>"; } ?> </select> </p> <p> <input type="submit" value="Delete"></p> </div> </form> </form> <div align="center"> <input name="BUTTON3" type="BUTTON" onClick="javascript:history.go(-1)" value="Back"> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
peranha Posted September 14, 2008 Share Posted September 14, 2008 to this line, just add the genre field echo "<option value=\"{$show['show']}\">{$show['show']}</option>"; echo "<option value=\"{$show['show']}\">{$show['show']} {$show['genre']}</option>"; That will put the genre in the dropdown menu. if that is what you are talking about. Quote Link to comment Share on other sites More sharing options...
grahamb314 Posted September 14, 2008 Author Share Posted September 14, 2008 Thats perfect thanks (and so simple!) One last thing. Doing that doesnt look very good, any suggestions to make lit look more presentable? - I mean by putting column headings in etc? - Or a better idea? - Your the expert! Quote Link to comment Share on other sites More sharing options...
peranha Posted September 14, 2008 Share Posted September 14, 2008 I dont think that you can put a table inside of a drop down. Quote Link to comment Share on other sites More sharing options...
grahamb314 Posted September 14, 2008 Author Share Posted September 14, 2008 is there any way to produce something with several columns that can be selected. EG I want to Delete the row which I select. A table with links? A drop down - Doesnt work Anything else? Quote Link to comment Share on other sites More sharing options...
peranha Posted September 14, 2008 Share Posted September 14, 2008 <?php $query = "SELECT * FROM table "; $result = mysql_query($query) or die ("<b class='red'>There is nothing on record</b>".mysql_error()); //... process contents of $result ... // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another echo "<table cellpadding=1 border=1 bgcolor='lightblue'>"; ?> <TR> <TH>header1</TH> <TH>header2</TH> </TR> <?php while($row = mysql_fetch_row($result)) { ?> <TR> <TD WIDTH="90"><a href=test.php><?php echo $row[0]; ?></a></TD> <TD WIDTH="90"><a href=test.php><?php echo $row[1]; ?></a></TD> </TR> <?php } ?> <?php } echo "</table>"; } ?> This will get a table and link what it outputs to test.php Quote Link to comment Share on other sites More sharing options...
grahamb314 Posted September 14, 2008 Author Share Posted September 14, 2008 When youpress one of the links, i take it that it will go to some php file and you can use post from there and then sql and php to delete that row with whatever post is? Quote Link to comment Share on other sites More sharing options...
peranha Posted September 14, 2008 Share Posted September 14, 2008 Yes that is correct, I have it going to test.php, you will have to change it to whatever page you want it to go to. EDIT You will not use post, you will use $_GET Links will look like this<a href=test.php?id=<?php echo $show['show']; ?> and on the next page, you will do $show = $_GET['id']; and do you sql queries from there. Quote Link to comment Share on other sites More sharing options...
grahamb314 Posted September 14, 2008 Author Share Posted September 14, 2008 Hmm looks interesting, I`ll have a look into GET then Thanks for your help anyway!!! Quote Link to comment 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.