emediastudios Posted June 3, 2008 Share Posted June 3, 2008 Hi everyone. Im still learning php and sql and will be for quite some time. I need a little help. I want a file to display all records in a page. the database name is "sde" and the table name is "salons" The fields in the record are: companyname tradingname acnabn streetaddress postaladdress salonownername salonemail salonwebsite contactmethod time survey comments I also wanted a delete function. Can someone point to me a tutorial on this? Or post a script i could alter to suit. Thanks Quote Link to comment Share on other sites More sharing options...
raku Posted June 3, 2008 Share Posted June 3, 2008 If you simply want to print all of the records in your table, do a while loop through the table and output what you want to see. For example: $query = "SELECT * FROM salons"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo $row['companyname'] . "," . $row['tradingname'] . "<br/>"; } This will output the company name and trading name for every company in your table. You can change up the way the output looks and use whatever fields you want. Regarding deleting a row: $companytodelete = "name of company to delete"; $query = "DELETE FROM salons WHERE companyname='$companytodelete'"; mysql_query($query); You can interchange the variables if you'd like to delete a company based off of another field. If you are going to take the companytodelete name from the user, you may want to escape it using mysql_real_escape_string. Hope this helps! Quote Link to comment Share on other sites More sharing options...
emediastudios Posted June 3, 2008 Author Share Posted June 3, 2008 your a champ. Thanks heaps, will have a go after dinner ;D 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.