|
-
Jan 2nd, 2006, 12:31 PM
#1
Thread Starter
Frenzied Member
PHP Basic Function Help
Okay, I'm still in the process of learning the basics of PHP. Currently I am interacting with MySql to 'spice' up my site.
At the moment, I am trying to create a function for simplifying the creation of tables via a function.
This would require the table name and it's values. The problem is the values can be 2 or 10, and are usually not the same. So my idea was to handle this with an array, but I need to know a few things first:
-Can you use an array as a paramter for a function
-How do you use that array as a paramter
-How do you get the upper bound of an array
If anyone could help explain the above it would be nice 
PHP Code:
<?php
include 'config.php'; //Sets up the database information
include 'connect.php'; //Connects the the database
function create_table($tablename, $values){
$query = 'CREATE TABLE $tablename, $values';
$result = mysql_query($query);
}
include 'close.php'; //Closes the connection
?>
Note: My idea was to create the values string by creating a loop that ran through all the values of the array and added them to another string like ", $Value1, $Value2" etc.
Age - 15 ::: Level - Advanced
If you find my post useful please ::Rate It::

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|