MDanz Posted August 25, 2009 Share Posted August 25, 2009 <form action='delete.php' method='post'> <select> <?php $sql='SELECT name FROM castack'; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ echo $data['name']; } ?> </select> <input type='submit' name='delete' value='Delete' /> </form> i have a list/menu and they are supposed to display the all the results in the database. I select what one and i press the delete button. this isn't working its not displaying whats in the database. Link to comment https://forums.phpfreaks.com/topic/171732-delete-form/ Share on other sites More sharing options...
Jezza Posted August 25, 2009 Share Posted August 25, 2009 I don't really get what you mean by this, more info please. Also, how knew are you to PHP? Link to comment https://forums.phpfreaks.com/topic/171732-delete-form/#findComment-905537 Share on other sites More sharing options...
MDanz Posted August 25, 2009 Author Share Posted August 25, 2009 sry i'll be clearer a drop down list with my results. And a delete button. this is what i attempted. But i'm not getting my results in the drop down list. <form action='added.php' method='post'> <select> <?php $sql='SELECT name FROM castack'; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ $delete=$data['name']; echo "$delete"; } ?> </select> <input type='submit' name='delete' value='Delete' /> </form> i'm quite new to php but i'm getting the hang of it Link to comment https://forums.phpfreaks.com/topic/171732-delete-form/#findComment-905539 Share on other sites More sharing options...
Cetanu Posted August 25, 2009 Share Posted August 25, 2009 $sql='SELECT FROM ...'; Should be: $sql=mysql_query("SELECT FROM...."); Also, you're not connecting to a database. You need to connect to a database to delete things from a table. AND, you should not do this: echo "$delete"; it should be echo $delete; You might want to go over to W3C Tutorials or Tizag or something you look a little discombobulated with PHP. Link to comment https://forums.phpfreaks.com/topic/171732-delete-form/#findComment-905541 Share on other sites More sharing options...
MDanz Posted August 25, 2009 Author Share Posted August 25, 2009 k i changed some stuff still not getting the results from database in drop down list.. <form action='added.php' method='post'> <select> <?php mysql_connect("localhost", "Master", "password"); mysql_select_db("db"); $sql=mysql_query("SELECT name FROM castack"); $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ $delete=$data['name']; echo $delete; } ?> </select> <input type='submit' name='delete' value='Delete' /> </form> Link to comment https://forums.phpfreaks.com/topic/171732-delete-form/#findComment-905545 Share on other sites More sharing options...
Cetanu Posted August 25, 2009 Share Posted August 25, 2009 You may want to include the <select> fields in the PHP code since you want a new select field for every name. <form action='added.php' method='post'> <?php mysql_connect("localhost", "Master", "password"); mysql_select_db("db"); $sql=mysql_query("SELECT name FROM castack"); $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ $delete=$data['name']; echo " <select>"; echo $delete; echo "</select>"; } ?> Will give you a box that will have an option for each name. <input type='submit' name='delete' value='Delete' /> </form> Link to comment https://forums.phpfreaks.com/topic/171732-delete-form/#findComment-905552 Share on other sites More sharing options...
robert_gsfame Posted August 25, 2009 Share Posted August 25, 2009 have u tried mysql_fetch_row and looping it Link to comment https://forums.phpfreaks.com/topic/171732-delete-form/#findComment-905748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.