You are here: Re: how do I remove products from a dynamically generated product catalogue? « All PHP « IT news, forums, messages
Re: how do I remove products from a dynamically generated product catalogue?

Posted by J.O. Aho on 10/10/19 11:33

Graeme wrote:
> The question is all in the title.
>
> My suppliers csv files have been used to populate a mySQL database
> and this has then been used to generate all of the product pages.
>
> Now I want to remove certain manufacturers entirely however, I
> don't know how. Thus I'd be grateful for any advice or perhaps a
> URL to a tutorial or help page on the subject?

Much depends on what tools you have that you can use to manipulate the
database with.

If you use the command line tool mysql, then you use the DELETE sql statement
to delete entries in your database.

http://dev.mysql.com/doc/refman/4.1/en/delete.html


First you need to login to the mysql:
mysql -u<username> -p

You will then be asked for the password and after that you will have the
following output (can be slightly different depending on version of mysql

--- from the terminal ---
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 255 to server version: 5.0.16-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
--- eof ---

now you need to select the database you want to modify

mysql> \u <name of database>

If you don't know the name of the database, you can type

mysql> show databases;

and you will get a list of databases, don't select mysql nor test.
Now you can list all the tables with

mysql> show tables;

--- example of result ---
+-------------------+
| Tables_in_mydatab |
+-------------------+
| Mark5 |
| Mark6 |
| Mark7 |
| NewsGroups |
| NewsGroups |
+-------------------+
5 rows in set (0.00 sec)
--- eof ---

You can get the column names for a table with the following

mysql> show columns in Mark6;

--- example of result ---
+-------+--------+------+-----+------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------+------+-----+------------+-------+
| Draw | date | YES | | 2003-01-01 | |
| Num | int(2) | YES | | 0 | |
| Extra | int(1) | YES | | 0 | |
+-------+--------+------+-----+------------+-------+
3 rows in set (0.10 sec)
--- eof ---

When you know which tables contains data about the manufacturers and what ID
number it may have (and what the ID column would be named), then you can
easily just type something like

mysql> delete from Mark6 where Draw='2003-01-01';

This example delete would delete all entries in Mark6 table which had the
column Draw having the value 2003-01-01. It's quite _important_ to have the
WHERE statement, or else you will delete ALL data in the table and you would
have a not working database as it would miss important data.


Maybe you have some other tools which makes it easier for you to manage the
database, MySQL have given out "MySQL Administrator 1.1", which gives you a
graphical frontend for you to administrate your databases.


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация