473,499 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

table exists in php MySql

I have 2 requirements that I don't know how to implement in php using
MySql.

1) I want to see if a particular table name exists.

2) I want an arrays with the column names that exist in a table.

can anyone help me out with that please?

Thanks
Jul 17 '08 #1
2 1511
NC
On Jul 17, 9:24 am, "soldier.coder" <geekprogrammer...@googlemail.com>
wrote:
>
I have 2 requirements that I don't know how to implement
in php using MySql.

1) I want to see if a particular table name exists.
Run a SHOW TABLES query; it will return a list of tables that exist in
the currently selected database. See MySQL documentation:

http://dev.mysql.com/doc/refman/5.1/en/show-tables.html
2) I want an arrays with the column names that exist in a table.
Run a SHOW COLUMNS query; it will return a list of fields that exist
in the specified table. See MySQL documentation:

http://dev.mysql.com/doc/refman/5.1/...w-columns.html

Cheers,
NC
Jul 17 '08 #2

"soldier.coder" <ge***************@googlemail.comwrote in message
news:48**********************************@r66g2000 hsg.googlegroups.com...
>I have 2 requirements that I don't know how to implement in php using
MySql.

1) I want to see if a particular table name exists.

2) I want an arrays with the column names that exist in a table.

can anyone help me out with that please?
rtfm.

both these questions are answered in the mysql manual and are well
documented - not hidden.
Jul 17 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2252
by: Sims | last post by:
Hi, Assuming the table MYTABLE, i want to run a script to backup the table. But there does not seem to be a straight forward function in MySQL to achieve it, Something like COPY TABLE...
1
4421
by: Fire Juggler | last post by:
On my website, the user can create tables, but how do i check if the table exists, and if it doesn't it creates the table? Thanks -- Kathryn (Fire Juggler) http://www.firejugglers.34sp.com...
2
11842
by: Jonathan | last post by:
I am looking for a simple way to check if a database table exists. I keep getting advice to use "Try.. Catch" and other error handling methods, but I obviously don't want to have to display an...
0
1162
by: Morten Gulbrandsen | last post by:
USE company; DROP TABLE IF EXISTS EMPLOYEE; CREATE TABLE EMPLOYEE ( # PK SSN CHAR(9) NOT NULL, # FK SUPERSSN CHAR(9), DNO INT NOT NULL DEFAULT 1, CONSTRAINT EMPPK
0
1375
by: Tim Johnson | last post by:
Hello All: I would like to rename a table if it exists. The following query IF EXISTS ALTER TABLE gwcc_members RENAME gwcc_members_bak; fails. also ALTER TABLE IF EXISTS gwcc_members...
2
13902
by: Alicia | last post by:
Does anyone know why I am getting a "Syntax error in Create Table statement". I am using Microsoft Access SQL View to enter it. Any other problems I may run into? CREATE TABLE weeks (...
5
3927
by: phillip.s.powell | last post by:
$sql = "SELECT IF((SHOW TABLES LIKE '$subselectTableName'), count(*), NULL) AS numRows FROM $subselectTableName"; I am trying to write a SQL statement that will tell me if a table exists or not,...
1
5821
by: bpforte | last post by:
Hello, I need help with building query, basically I need to select all records from one table that don't exists in second table with status 1, but they can exists in second table with status 0, to...
4
22458
by: Bob | last post by:
Hi all, I've got a table that I've imported and it has junk at the top of the table, so after import I run a delete query to remove the junk lines then I'm left with the field names I want for...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.