Return to iWEBTOOL

Go Back   iWEBTOOL Talk > The Web and your Website > Programming > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
Welcome to iWEBTOOL Talk, where you talk about webmaster-related stuff.
 
Discuss topics which interest you.
With over thousands of threads (topics), we're sure you'll find something that'll interest you.
Ask for help whenever you need it.
We have thousands of members who are available to help you if you need it.
It's absolutely FREE!

 1  Register           2  Browse the board           3  Discuss whatever may interest you!
 


Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 10-11-2006, 03:24 AM   #1
lip9000
Newcomer
 
lip9000's Avatar
 
Join Date: Oct 2006
Posts: 2
lip9000 will become famous soon enough
Default *Majorly STUCK!* Professional NEEDED!!!

I have made a website for an athletics club and currently have to add in manually a table in dreamweaver and type in each new record that the athletes achieve each week.

I wish to make it dynamic so that they can add in all the records themselves without having to email them to me to put in manually. It's difficult to do because each week there is a new set of records that i have to add in, therefore i would have to add in a new MySQL table for each week with the appripriate fields.

I am using PHP, how can I set it up so that there is a page where you can insert a new TABLE into the database via the web browser, just by typing the name into a field and clicking insert, and it adds that table into the database with the fields already set up for it.

Then the next page I want to be able to add in each row of records that the athletes have and then display them all on a page. Here's an example of what i mean http://www.forestlakeslac.com/docs/records.html

Here you can see what I mean, how would i go about making it dynamic?

HUGE HUGE thanks to whoever can solve this, and your a legend if u can
lip9000 is offline  
 
This is an Ad Revenue Sharing forum Place your advert here
SEO Checklist
Get yourself better ranking with
our "Do-it-Yourself" SEO Checklist.
Click Here
Old 10-11-2006, 05:06 AM   #2
GDLEE
Junior Member
 
GDLEE's Avatar
 
Join Date: Oct 2006
Posts: 32
GDLEE will become famous soon enough
Default Re: *Majorly STUCK!* Professional NEEDED!!!

If I am understanding you correctly, this would be fairly easy to do. Create a form with fields for the table name and each field for that table. The user submits that page and the mysql table and fields are created. The user can then pull up that table and enter the data themselves.

To do this I would post the data to a script that will look something like this:

$query = 'CREATE TABLE $tablename( '.
'$field1 INT NOT NULL AUTO_INCREMENT, '.
'$field2 VARCHAR(20) NOT NULL, '.
'$field3 VARCHAR(50) NOT NULL, '.
'$field4 VARCHAR(30) NOT NULL, '.
'$field5 TEXT NOT NULL, ';


I did not include all of the php required as you seem to have some knowledge of it.

You will want to be careful about security or add a user login as you don't want anyone just being able to create tables at random and want to avoid mysql injection.

PM me for further help if needed. I could probably write this for you in a day but right now I am very busy but I will help all I can find time for.

PS> That webserver you are hosting that on seems very slow.
GDLEE is offline  
Old 10-11-2006, 03:40 PM   #3
lip9000
Newcomer
 
lip9000's Avatar
 
Join Date: Oct 2006
Posts: 2
lip9000 will become famous soon enough
Default Re: *Majorly STUCK!* Professional NEEDED!!!

Thanks for that, you seem to understand my situation. I cant PM you because it says i need to have more than 10 posts and ive only made 1.

This is what i have so far:

A page called addtable.php, it contains only a form and no php code. The text field name is "tablename" which is posted to the next page.

<form id="form1" name="form1" method="post" action="stuff.php">
<p>Table Name:
<input name="tablename" type="text" id="tablename" />
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>


The page that the form action is set to is called stuff.php It contains the connection and the code to create the new table.

<?php require_once('Connections/conn.php'); ?>
<?php

$tablename = $_POST['tablename'];

$sql = 'DROP TABLE IF EXISTS `zonessss`';
mysql_query( $sql, $conn );

$sql = 'CREATE TABLE $tablename (
`zid` TINYINT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT,
`zdesc` VARCHAR( 150 ) NOT NULL,
`zwidth` SMALLINT( 3 ) DEFAULT 0 NOT NULL,
`zheight` SMALLINT( 3 ) DEFAULT 0 NOT NULL,
`zmax` MEDIUMINT(7) unsigned NOT NULL default 12288,
PRIMARY KEY ( `zid` )
)';
echo "Creating table: $tablename";
mysql_query( $sql, $conn );

?>


This doesnt yet work though, whenever I run it, the new table doesnt get added to the database. I was playing around with it before and somehow got it to work and it added the new table in, unfortunately i cant remember how i did it. But also, it did not name that table to the name that i entered into the text field on 'addtable.php', instead the name of the database was the variable name that i assiged it to '$tablename'. So the table was there with all the correct fields in but its name was $tablename.

Any suggestions??

PS> Sorry for the slow host speed, that site is hosted on my own home server running off my ADSL connection with a 256k upload. Will upgrade eventually.
lip9000 is offline  
Old 10-11-2006, 04:29 PM   #4
GDLEE
Junior Member
 
GDLEE's Avatar
 
Join Date: Oct 2006
Posts: 32
GDLEE will become famous soon enough
Default Re: *Majorly STUCK!* Professional NEEDED!!!

Try this, it worked for me.

<?php require_once('Connections/conn.php'); ?>
<?php

$tablename = $_POST['tablename'];

$sql = 'DROP TABLE IF EXISTS `zonessss`';
$qry=mysql_query($sql)or die(mysql_error());

$sql = "CREATE TABLE $tablename (
`zid` TINYINT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT,
`zdesc` VARCHAR( 150 ) NOT NULL,
`zwidth` SMALLINT( 3 ) DEFAULT 0 NOT NULL,
`zheight` SMALLINT( 3 ) DEFAULT 0 NOT NULL,
`zmax` MEDIUMINT(7) unsigned NOT NULL default 12288,
PRIMARY KEY ( `zid` )
)";
echo "Creating table: $tablename";

$qry=mysql_query($sql)or die(mysql_error());

?>


Email me instead. I can't PM either yet.

FYI, adding this or die(mysql_error()); to your queries can really help debug things, in case you didn't know. Remove them before putting them live as showing the errors can give hackers an insight to your mysql structure.
GDLEE is offline  
 
This is an Ad Revenue Sharing forum Place your advert here
Webmaster Tools Webmaster Tools Click Here
Closed Thread

(Threads which have no activity for more than 30 days are automatically closed.)



Quick Reply
Message:

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is your Professional? dreamsubmitting General Talk 4 10-04-2006 11:20 PM
How to Be Professional Online compuXP Web Development 5 10-01-2006 05:27 PM
Does my site look professional? Albert Tai Website Reviews 8 06-14-2006 02:20 AM


All times are GMT. The time now is 10:06 PM.


Powered by vBulletin v3.6.7 © 2008, Jelsoft Enterprises Ltd. SEO by vBSEO © 2006, Crawlability, Inc.