Jump to content

dalying php


bamfon

Recommended Posts

<?php
include "./config.php";

if(isset($_POST['name'])) { 



$sql = 'CREATE TABLE `'.$_POST['name'].'` (
        `ep` int(11) NOT NULL AUTO_INCREMENT,
        `title` varchar(150) NOT NULL,
        `type` varchar(150) NOT NULL,
        `episode` varchar(150)  NOT NULL,
        `year` varchar(150) NOT NULL,
        `status` varchar(150) NOT NULL,
	`summary` varchar(150) NOT NULL,
        PRIMARY KEY (`ep`)
       )';

$king = $_POST['name'];

error_reporting(E_ALL);
ini_set('display_errors', '1');
}?> 

    <?php 



$title = $_POST['title'];
$type = $_POST['type'];
$episodes = $_POST['episodes'];
$year = $_POST['year'];
$genre = $_POST['genre'];
$status = $_POST['status'];
$summary = $_POST['summary'];
$pic = $_POST['pic'];






$sql="INSERT INTO $king
(title, type, episode, year, genre, status, summary, pic)
VALUES
('$title','$type','$episodes','$year','$genre','$status','$summary','$pic')";


if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }
echo "1 Anime added";





error_reporting(E_ALL);
ini_set('display_errors', '1');

?>

 

i want it delay everything after $title = $_POST['title']; so it has time to save the table before adding in the info

 

i tryed using sleep but it dont work

Link to comment
https://forums.phpfreaks.com/topic/223796-dalying-php/
Share on other sites

No, it's a nightmare way to design a database.

 

From what I can see, you should only need a few tables.

 

table_anime

table_anime_episodes

table_categories

 

You can easily create a relationship between these tables without creating a new table per anime. Imagine if you insert 10,000 anime shows..by your current design you will be creating 10,000 tables. Cmon, surely you can see there must be a better way? That better way is above ^^

 

table_anime has an id, which is refered to in tabel_anime_episodes, table_categories has an id which is refered to in table_anime. Something like:

 

table_anime.ID = table_anime_episodes.anime_ID

table_anime.cat_ID = table_categories.ID

 

Now you can insert a MILLION anime shows (not sure if that many exist ;) and you will be able to manage the data *with ease*. If you're not careful you are going to create for yourself a big big headache.

 

Link to comment
https://forums.phpfreaks.com/topic/223796-dalying-php/#findComment-1156755
Share on other sites

<?php
include "./config.php";

if(isset($_POST['name'])) { 



$sql = 'CREATE TABLE `'.$_POST['name'].'` (
        `ep` int(11) NOT NULL AUTO_INCREMENT,
        `title` varchar(150) NOT NULL,
        `type` varchar(150) NOT NULL,
        `episode` varchar(150)  NOT NULL,
        `year` varchar(150) NOT NULL,
        `status` varchar(150) NOT NULL,
	`summary` varchar(150) NOT NULL,
        PRIMARY KEY (`ep`)
       )';

$king = $_POST['name'];

error_reporting(E_ALL);
ini_set('display_errors', '1');
}?> 

    <?php 



$title = $_POST['title'];
$type = $_POST['type'];
$episodes = $_POST['episodes'];
$year = $_POST['year'];
$genre = $_POST['genre'];
$status = $_POST['status'];
$summary = $_POST['summary'];
$pic = $_POST['pic'];






$sql="INSERT INTO $king
(title, type, episode, year, genre, status, summary, pic)
VALUES
('$title','$type','$episodes','$year','$genre','$status','$summary','$pic')";


if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }
echo "1 Anime added";





error_reporting(E_ALL);
ini_set('display_errors', '1');

?>

 

i want it delay everything after $title = $_POST['title']; so it has time to save the table before adding in the info

 

i tryed using sleep but it dont work

 

I fully agree with anti-moronic, also....:

so it has time to save the table before adding in the info

 

Come on, admit it, you just want it to say "Creating table...." THEN say Done or something...right, please?

You realize it'll hang until it completes it, or die due to syntax/maximum execution time/memory exceeded/whatever.

Link to comment
https://forums.phpfreaks.com/topic/223796-dalying-php/#findComment-1156758
Share on other sites

 

Come on, admit it, you just want it to say "Creating table...." THEN say Done or something...right, please?

You realize it'll hang until it completes it, or die due to syntax/maximum execution time/memory exceeded/whatever.

I really dont

 

Also thanks Anti-Moronic i will look in to doing it that way

Link to comment
https://forums.phpfreaks.com/topic/223796-dalying-php/#findComment-1156774
Share on other sites

 

Come on, admit it, you just want it to say "Creating table...." THEN say Done or something...right, please?

You realize it'll hang until it completes it, or die due to syntax/maximum execution time/memory exceeded/whatever.

I really dont

 

Also thanks Anti-Moronic i will look in to doing it that way

 

No problem. Please do come back if you have trouble implementing things this way! Be glad to help.

Link to comment
https://forums.phpfreaks.com/topic/223796-dalying-php/#findComment-1156780
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.