Olá a todos, sou novo na área de multimídia. Estou a seguir a um momento um ebook sobre a criação de uma base de dados e também a criação de tabelas. Mas quando vinculei as tabelas do banco de dados, no phpmyadmin me deu alguns erros. Fiz a correspondência da chave primária (artist_id da tabela Artist) com a artist_id da tabela Prints (chave estrangeira) e assim por diante. O problema é que ele não mostra minhas relações das tabelas e me dá uma mensagem de erro. Então, alguns de vocês poderiam me ajudar, por favor, a consertar esta situação. Eu serei grato. Cumprimentos.
Ps .: Abaixo envio o arquivo Sql.
Atentamente,
José Moreira
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jan 07, 2021 at 08:49 PM
-- Server version: 10.4.14-MariaDB
-- PHP Version: 7.2.33
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `ecommerce`
--
-- --------------------------------------------------------
--
-- Table structure for table `artists`
--
CREATE TABLE `artists` (
`artist_id` int(10) UNSIGNED NOT NULL,
`first_name` varchar(20) DEFAULT NULL,
`middle_name` varchar(20) DEFAULT NULL,
`last_name` varchar(40) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `customers`
--
CREATE TABLE `customers` (
`customer_id` int(10) UNSIGNED NOT NULL,
`email` varchar(60) NOT NULL,
`pass` char(40) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`order_id` int(10) UNSIGNED NOT NULL,
`customer_id` int(10) UNSIGNED NOT NULL,
`total` decimal(10,2) UNSIGNED NOT NULL,
`order_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `order_contents`
--
CREATE TABLE `order_contents` (
`oc_id` int(10) UNSIGNED NOT NULL,
`order_id` int(10) UNSIGNED NOT NULL,
`print_id` int(10) UNSIGNED NOT NULL,
`quantity` tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
`price` decimal(6,2) UNSIGNED NOT NULL,
`ship_date` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `prints`
--
CREATE TABLE `prints` (
`print_id` int(10) UNSIGNED NOT NULL,
`artist_id` int(10) UNSIGNED NOT NULL,
`print_name` varchar(60) NOT NULL,
`price` decimal(6,2) UNSIGNED NOT NULL,
`size` varchar(60) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`image_name` varchar(60) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `artists`
--
ALTER TABLE `artists`
ADD PRIMARY KEY (`artist_id`),
ADD UNIQUE KEY `full_name` (`last_name`,`first_name`,`middle_name`);
--
-- Indexes for table `customers`
--
ALTER TABLE `customers`
ADD PRIMARY KEY (`customer_id`),
ADD UNIQUE KEY `email` (`email`),
ADD KEY `login` (`email`,`pass`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`order_id`),
ADD KEY `customer_id` (`customer_id`),
ADD KEY `order_date` (`order_date`);
--
-- Indexes for table `order_contents`
--
ALTER TABLE `order_contents`
ADD PRIMARY KEY (`oc_id`),
ADD KEY `order_id` (`order_id`),
ADD KEY `print_id` (`print_id`),
ADD KEY `ship_date` (`ship_date`);
--
-- Indexes for table `prints`
--
ALTER TABLE `prints`
ADD PRIMARY KEY (`print_id`),
ADD KEY `artist_id` (`artist_id`),
ADD KEY `print_name` (`print_name`),
ADD KEY `price` (`price`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `artists`
--
ALTER TABLE `artists`
MODIFY `artist_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
MODIFY `customer_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
MODIFY `order_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `order_contents`
--
ALTER TABLE `order_contents`
MODIFY `oc_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `prints`
--
ALTER TABLE `prints`
MODIFY `print_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
class Data {
public static function ExibirTempoDecorrido($date)
{
if(empty($date))
{
return "Informe a data";
}
$periodos = array("segundo", "minuto", "hora", "dia", "semana", "mês", "ano", "década");
$duracao = array("60","60","24","7","4.35","12","10");
$agora = time();
$unix_data = strtotime($date);
// check validity of date
if(empty($unix_data))
{
return "Bad date";
}
// is it future date or past date
if($agora > $unix_data)
{
$diferenca = $agora - $unix_data;
$tempo = "atrás";
}
else
{
$diferenca = $unix_data - $agora;
$tempo = "agora";
}
for($j = 0; $diferenca >= $duracao[$j] && $j < count($duracao)-1; $j++)
{
$diferenca /= $duracao[$j];
}
$diferenca = round($diferenca);
if($diferenca != 1)
{
$periodos[$j].= "s";
}
return "$diferenca $periodos[$j] {$tempo}";
}
}
Funciona redondinho se o valor retornado for de algumas horas, mas...
Quando passa de dois meses, ele retorna a palavra mess. Deve ser por conta dessa linha
if($diferenca != 1)
{
$periodos[$j].= "s";
}
Olá...
Estou tentando fazer o seguinte !!
Listando dados em tabela !!
Gostaria que....se na listagem houver 4 linhas...indepedente de seu número de ID, faça a listagem em ID ser em ordem 1 2 3 4 !!
Exemplo...se tiver uma listagem de dados que está em ID 1 3 3...faça ficar 1 2 3 !!
Eu uso o tinymce para cadastro de textos no meu siite, porém, quero fazer um sistema para que os colunistas possam fazer o próprio post.
O problema do tinymce, é que ele mantém a formatação do texto copiado, como tamanho de fonts, negritos, etc... Quero que o usuário cole o texto e a própria textarea limpe a formatação para que ele formate como quiser.
A pergunta é:
O tinymce tem uma opção para desabilitar a formatação quando um texto é colocado?
Tem alguma função via java ou php para retirar a formatação assim que o texto é colado?
Ou é melhor usar um outro editor?
Olá a todos!
Tenho uma pagina que possui uma DIV onde coloquei uma pagina PHP.
Uso a função setInterval para atualizar a pagina inclusa dentro da DIV.
O problema é que ao acessar o site , a DIV só me mostra a pagina inclusa somente quando completo o primeiro minuto.
Preciso que a pagina inclusa já inicie carregada
Meu código JavaScript e a DIV com a pagina PHP
<script>
function atualiza(){
var url = 'direita.php';
$.get(url, function(dataReturn) {
$('#direita').html(dataReturn);
});
}
setInterval("atualiza()",60000);
</script>
<div>
<span id="direita"></span>
</div>
Quero selecionar duas tabelas e mostrar com resultados intercalados. Abaixo segue um código explicando para vcs terem uma ideia.
$consulta = "SELECT A.*, B.* FROM tabela1 A, tabela2 B'";
$resultado = mysqli_query($conexao, $consulta) or die ("erro");
while($busca = mysqli_fetch_array($resultado)){
print $busca['cod_evento']; --> traz o código da tabela1
print $busca['titulo_evento']; --> traz o titulo da tabela1
print $busca['cod_noticia']; --> traz o código da tabela2
print $busca['titulo_noticia']; --> traz o tituloda tabela2
Olá a todos, sou novo na área de multimídia. Estou a seguir a um momento um ebook sobre a criação de uma base de dados e também a criação de tabelas. Mas quando vinculei as tabelas do banco de dados, no phpmyadmin me deu alguns erros. Fiz a correspondência da chave primária (artist_id da tabela Artist) com a artist_id da tabela Prints (chave estrangeira) e assim por diante. O problema é que ele não mostra minhas relações das tabelas e me dá uma mensagem de erro. Então, alguns de vocês poderiam me ajudar, por favor, a consertar esta situação. Eu serei grato. Cumprimentos.
Ps .: Abaixo envio o arquivo Sql.
Atentamente,
José Moreira
Compartilhar este post
Link para o post
Compartilhar em outros sites