re
Moderator: General Moderators
re
not if there is tables, but if a certain table exists, like how do you see if theres a table named _topic1 in the database?
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
lol
how about you give me an if() statement to see if a table called _table exists. if it does exist, $x = 1. if no, $x = 0. just give me tha code, thx ;D
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
im going to assume you are very new to php and therefore do not have much experience in doing a little research in the manual. thats fine but try to keep in mind for the future, we are here to help you, not to code your problems away. i have gained and provided much help here and i hope you will in the future.
with that said here is a script that should help you out. i have left it up to you to deal with the part indicated in the if statement:
with that said here is a script that should help you out. i have left it up to you to deal with the part indicated in the if statement:
Code: Select all
<?php
//assume connection is already open using mysql_connect()
$table = "my_lost_table";
$result = mysql_list_tables("mydmnsn");
$num = mysql_num_rows($result);
for ($i = 0; $i < $num; $i++) {
if ($table == mysql_result($result, $i, 0)) {
//the table was found, now do something with it
print "$table found at index $i";
break;
}
}
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: lol
How about you do your own work? mydimension was very kind in giving you an answer which you really didn't deserve. This is not a script writing service and if in the future you can't be bothered to actually put suggestions into practise I suggest that you go to the Jobs Forum and hire someone to do the work for you.pb2ya wrote:how about you give me an if() statement to see if a table called _table exists. if it does exist, $x = 1. if no, $x = 0. just give me tha code, thx ;D
Mac
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
:)
ok thx, im new to php, and thx again.
BTW- im NEVER gonna hire some1 for work i can do mahself. ok that was hypocritical kinda
. anyways, the php.net manual was down, and mah php book didnt help either, thx anyways for the critisicm.
plz excuse mah spelling. hope phpbb3.0 has spell chack
BTW- im NEVER gonna hire some1 for work i can do mahself. ok that was hypocritical kinda
plz excuse mah spelling. hope phpbb3.0 has spell chack
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Re: :)
No offense, but I think you'd probably break it.pb2ya wrote:plz excuse mah spelling. hope phpbb3.0 has spell chack