Jump to content

Show records


emediastudios

Recommended Posts

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.