Skip to content

Instantly share code, notes, and snippets.

@ricardosiri68
Last active December 25, 2015 11:39
Show Gist options
  • Save ricardosiri68/6970709 to your computer and use it in GitHub Desktop.
Save ricardosiri68/6970709 to your computer and use it in GitHub Desktop.
--
-- Database: `images`
--
-- --------------------------------------------------------
--
-- Table structure for table `imagenes`
--
CREATE TABLE IF NOT EXISTS `positions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cat` varchar(70) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `positions`
--
INSERT INTO `positions` (`id`, `cat`) VALUES
(1, 'page1' ),
(2, 'page2'),
(3, 'page3'),
(4, 'page4'),
(5, 'page5'),
(6, 'page6'),
(7, 'page7');
--
-- Constraints for dumped tables
--
--
-- Constraints for table `positions`
--
CREATE TABLE IF NOT EXISTS `imagenes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(36) NOT NULL,
`position_id` int(11) NOT NULL REFERENCES positions (id),
`ruta` varchar(54) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
--
-- Dumping data for table `imagenes`
--
-- --------------------------------------------------------
--
-- Table structure for table `positions`
--
<?
$query = "SELECT * FROM imagenes WHERE name='$name'";
$query_scan = $conections->query($query);
$num_regs = $query_scan->num_rows;
//si no existe el video se da de alta
if ( $num_regs == 0)
//insertion
{
$query = "INSERT INTO imagenes (name,position_id,ruta) VALUES
('$name',$categoria,'$ruta')";
echo $query;
$query_scan = $conections->query(utf8_encode($query));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment