Login | Register | FAQ
Anonymous

MySQL JQuery Drag Resize Problem

+ Post a reply

4 posts Page 1 of 1


MySQL JQuery Drag Resize Problem

by themenaceman » Thu May 17, 2012 12:53 pm

Hello all, Can anyone tell me what im doing wrong. I'm trying to create a dynamic page where the divs are created according to the data in my database such as width, height, top and left, I then want the divs dragable and resizable. I can Create a dynamic page and can create a dragable and resizable static page but connot combine the two. Here is my code...

<?php
session_start();
include ("connect_to_mysql.php");
mysql_select_db("LEFT BLANK ON PURPOSE", $con);
//$userid = $_SESSION['id'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/>
</head>
<body>
<?php
$divnum = 0;
$result = mysql_query("SELECT * FROM Divs WHERE pageid= '1'");
while($row = mysql_fetch_array($result))
{
$divnum = $divnum + 1;
$pos_x = $row['pos_x'];
$pos_y = $row['pos_y'];
$width = $row['width'];
$height = $row['height'];
$bg_colour = $row['bg_colour'];
?>
<div id="<?php echo 'Div '.$divnum ?>" style=" position:absolute; top: <?php echo $pos_y ?>; left:<?php echo $pos_x ?>; width:<?php echo $width ?>; height:<?php echo $height ?>; background-color:<?php echo $bg_colour ?>; "><?php echo 'Div '.$divnum ?></div>
<script type="text/javascript">
$('#<?php echo 'Div '.$divnum ?>')
.draggable()
.resizable();
</script>
<? } ?>


</body>
</html>

Any help is much appreciated oh and here is the URL. http://monsterwebdesigns.co.uk/sqldiv.php
User avatar

themenaceman

  • Posts: 5
  • Joined: Sat Mar 31, 2012 10:44 pm

Re: MySQL JQuery Drag Resize Problem

by XainPro » Thu May 17, 2012 2:26 pm

would you please like to share the table dump/asl as well .. ?
its good goal to get that ll div's top left and height width will come from database..
User avatar

XainPro

  • Posts: 3562
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: MySQL JQuery Drag Resize Problem

by themenaceman » Thu May 17, 2012 3:44 pm

XainPro wrote:would you please like to share the table dump/asl as well .. ?
its good goal to get that ll div's top left and height width will come from database..


I hope this is what you mean by table dump.

-- phpMyAdmin SQL Dump
-- version 2.11.11.3
-- http://www.phpmyadmin.net
--
-- Host: 188.121.40.52
-- Generation Time: May 17, 2012 at 08:40 AM
-- Server version: 5.0.92
-- PHP Version: 5.3.2

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `LEFT BLANK ON PURPOSE`
--

-- --------------------------------------------------------

--
-- Table structure for table `Divs`
--

CREATE TABLE `Divs` (
`divid` int(11) NOT NULL auto_increment,
`userid` varchar(255) NOT NULL,
`pageid` varchar(255) NOT NULL,
`pos_x` varchar(255) NOT NULL,
`pos_y` varchar(255) NOT NULL,
`width` varchar(255) NOT NULL,
`height` varchar(255) NOT NULL,
`bg_colour` varchar(255) NOT NULL,
`bdr_colour` varchar(255) NOT NULL,
`bdr_radius` varchar(255) NOT NULL,
`fnt_colour` varchar(255) NOT NULL,
`fnt_style` varchar(255) NOT NULL,
`fnt_size` varchar(255) NOT NULL,
PRIMARY KEY (`divid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

--
-- Dumping data for table `Divs`
--

INSERT INTO `Divs` VALUES(1, '', '1', '200px', '5px', '800px', '460px', '#00FF00', '', '', '', '', '');
INSERT INTO `Divs` VALUES(2, '', '1', '205px', '10px', '790px', '100px', '#FF0000', '', '', '', '', '');
INSERT INTO `Divs` VALUES(3, '', '1', '205px', '115px', '150px', '300px', '#FF0000', '', '', '', '', '');
INSERT INTO `Divs` VALUES(4, '', '1', '360px', '115px', '635px', '300px', '#FF0000', '', '', '', '', '');
INSERT INTO `Divs` VALUES(5, '', '1', '205px', '420px', '790px', '40px', '#FF0000', '', '', '', '', '');
User avatar

themenaceman

  • Posts: 5
  • Joined: Sat Mar 31, 2012 10:44 pm

Re: MySQL JQuery Drag Resize Problem

by XainPro » Sat May 19, 2012 6:54 am

yah exectly that's called dump any how i like the idea to move the div by jquery and its coordinates such as left top should be saved in database its good idea i will work on it..
User avatar

XainPro

  • Posts: 3562
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1

?>