Page 1 of 1

re

Posted: Fri Oct 04, 2002 9:19 pm
by pb2ya
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?

Posted: Fri Oct 04, 2002 10:27 pm
by mydimension
the reply to your last post provided a solution to your question. that function will give you a list of tables and all you have to do is find out if the one in question is in that list.

lol

Posted: Fri Oct 04, 2002 10:42 pm
by pb2ya
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

Posted: Fri Oct 04, 2002 11:36 pm
by mydimension
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:

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;
    }
}
?>

Re: lol

Posted: Sat Oct 05, 2002 6:22 am
by twigletmac
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
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.

Mac

Posted: Sat Oct 05, 2002 9:21 am
by mydimension
thank you mac :)

:)

Posted: Sat Oct 05, 2002 3:37 pm
by pb2ya
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 :lol: . 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 :D

Re: :)

Posted: Sat Oct 05, 2002 4:44 pm
by hob_goblin
pb2ya wrote:plz excuse mah spelling. hope phpbb3.0 has spell chack :D
No offense, but I think you'd probably break it.