Jump to content

Orionsbelter

Members
  • Posts

    493
  • Joined

  • Last visited

Posts posted by Orionsbelter

  1. HI thank you for your reply, there is no mysql_error or php errors been displayed.

     

    on the print_r it gives < Dress [editor] => [Colour] => Black => size 6 [price] => 0.00 [update] => Update ) it seems that the editor still is been posted as blank even though i enter some text into the field.

     

    :(

     

    it seems to be picking up the textarea but not value :(

  2. 
    <?php
    session_start();
    $username=$_SESSION['username'];
    include_once"../includes/db_connect.php";
    $start=$_GET['start'];
    $id=$_GET['id'];
    
    if($_POST['startButton'] && $_POST['name']){
    $name=$_POST['name'];
    mysql_query("INSERT INTO  `products` (  `id` ,  `name` ) VALUES ('',  '$name');");
    $insert_id=mysql_insert_id();
    header("Location: addProduct.php?id=$insert_id");
    }
    $products=mysql_fetch_object(mysql_query("SELECT * FROM `products` WHERE `id`='$id'"));
    $categories=mysql_fetch_object(mysql_query("SELECT `name` FROM `categories` WHERE `departmentID`='$products->department'"));
    $subCategories=mysql_fetch_object(mysql_query("SELECT `name` FROM `subCategories` WHERE `catergoryID`='$products->category'"));
    if($products->department=="1"){$depart="Collections";}
    if($products->department=="2"){$depart="Accessories";}
    if($products->department=="3"){$depart="Childrens Wear";}
    
    if($products->subcategory=="0"){$breadCat="$depart > $categories->name";}else{$breadCat="$depart > $categories->name >  $subCategories->name";}
    
    if($_POST['update']){
    $editor=$_POST['editor'];
    $price=$_POST['price'];
    mysql_query("UPDATE `products` SET `price`='$price' WHERE `id`='$id'");
    mysql_query("UPDATE `products` SET `description`='$editor' WHERE `id`='$id'");
    echo"$editor <<";
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DT$breadCatD 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=utf-8" />
    <link href="../includes/main.css" rel="stylesheet" type="text/css" media="all"/> 
    <!-- Combo-handled YUI CSS files: -->
    <link rel="stylesheet" type="text/css" href="../includes/skin.css">
    <!-- Combo-handled YUI JS files: -->
    <script type="text/javascript" src="../includes/editor.js"></script>
    <title></title>
    <style type="text/css">
    #contentBox {
    background:#EEE;
    border:5px #333 solid;
    width:917px;
    padding:5px;
    color:#000;
    font-weight: bold;
    }
    #space {
    width:100%;
    height:15px;
    }
    .productName {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 18px;
    }
    .price {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 16px;
    }
    .titleBox{
    height:22px;
    width:600px;
    background-color:#CCC;
    border:#333 1px solid;
    font-family:Tahoma, Geneva, sans-serif;
    font-size:14px;
    }
    #titleHead{
    width:99%;
    height:18px;
    background-color:#333;
    font-family:Verdana, Geneva, sans-serif;
    font-size:14px;
    font-weight:bold;
    color:#FFF;
    padding:3px;
    }
    #main{
    width:99%;
    background-color:#999;
    font-family:Tahoma, Geneva, sans-serif;
    font-size:12px;
    color:#000;
    font-weight:normal;
    padding:3px;
    }
    .priceInput{
    height:18px;
    width:70px;
    font-family:Tahoma, Geneva, sans-serif;
    font-size:12px;
    color:#000;
    }
    .yui-skin-sam .yui-toolbar-container .yui-toolbar-inserticon span.yui-toolbar-icon {
        background-image: url( ../images/icons/smile/suits_default.gif );
        background-position: 4px 1px;
    height:18px;
    width:23px;
    }
    .yui-skin-sam .yui-toolbar-container .yui-button-insertdate-selected span.yui-toolbar-icon {
        background-image: url( ../images/icons/smile/suits_active.gif );
        background-position: 4px 1px;
    height:18px;
    width:23px;
    }
    #iconMenu {
    border:#999 1px solid;
    background:#f5f5f5;
    }
    .imgIc{
    border:0px;
    padding:2px;
    }
    .imgIc:hover{
    border:#666 1px solid;
    padding:2px;
    }
    </style>
    <script type="text/javascript">
    function validateForm()
    {
    var department=document.forms["form3"]["jumpMenu3"].value;
    var department=document.forms["form3"]["jumpMenu3"].value;
    var department=document.forms["form3"]["jumpMenu3"].value;
    
    
    }
    </script>
    </script>
    
    </head>
    
    <body class="yui-skin-sam">
    <?php include"../header.php";?>
    <div id="mainBody" align="center">
    <div id="mainBodyContainer" align="left">
    <div id="space"></div>
    <div id="contentBox">
      <form id="form" name="form" method="post" action=""><span class="productName" style="padding-bottom:6px;">Product Name</span><br />
          <input name="name" type="text" class="titleBox" id="name" value="<?php echo"$products->name";?>" />
        <br />
         <br />
        <label>
          <?php if($start=="0"){ ?>
          <input name="startButton" type="submit" id="startButton" value="Update" />
          <br />
          <br />
        </label>
         <div id="titleHead">Unfinished Product</div>
    <div id="main">
    <?php 
    $query=mysql_query("SELECT `name`, `id` FROM `products` WHERE `price`='0.00' OR `category`='0'");
    while($fetch=mysql_fetch_object($query)){
     echo"<a href=\"addProduct.php?id=$fetch->id\">$fetch->name</a><br>";
    }
    ?>
    <br />
       </div>
    <br />
    <?php } if($start!=="0"){ ?>
    <div id="titleHead">Select Master Category</div>
      <div id="main"><a href="addMaster.php?id=<?php echo"$id";?>" class="links">Add Master Category</a><br />
        <br />
       <span class="text1"><?php echo"$breadCat"; ?></span>
      </div>
      <br />
      <div id="titleHead">Product Images</div>
      <div id="main">
        <iframe src="upload.php?id=<?php echo"$id";?>" height="200" width="98%" style="border:none;"></iframe>
      </div>
      <br />
      <div id="titleHead">Product Description </div>
      <div id="main"><label><textarea id="editor" name="editor" rows="20" cols="75"></textarea> </label></div>
       <br />
      <div id="titleHead">Product Variants</div>
      <div id="main"><a href="addVariant.php?id=<?php echo"$id";?>" class="links">Add A Variant</a><br />
        <br />
    <?php 
    $queryVariants=mysql_query("SELECT `name`, `id` FROM `variants` WHERE `productID`='$id'");
    while($fetchVariants=mysql_fetch_object($queryVariants)){
    echo'
     <label>
       '. $fetchVariants->name.':
          <select name="'.$fetchVariants->name.'" id="'.$fetchVariants->name.'">';
    $queryVO=mysql_query("SELECT `name` FROM `variantsOptions` WHERE `productID`='$id' AND `variantID`='$fetchVariants->id'");
    while($fetchVO=mysql_fetch_object($queryVO)){
    echo"<option value='".$fetchVO->name."'>".$fetchVO->name."</option>";
    }
         echo'</select>
        </label>
        <a href="addVariant.php?id='.$id.'&edit=1&vid='.$fetchVariants->id.'">[edit]</a><br />';
    }
    ?>
      </div>
       <br />
      <div id="titleHead">Advanced Options</div>
      <div id="main"><a href="catManage.php?id=<?php echo"$id"?>" class="links">Category Management
        </a><br />
      </div>
      <p><span class="price">Price:</span> £
        <label>
      <input name="price" type="text" class="priceInput" id="price" value="0.00" />
    </label>
      </p>
        <label>
          <input name="update" type="submit" id="update" value="Update" />
        </label>
        <?php } ?>
      </form>
    </div>
    <div id="space"></div>
    </div>
    </div>
    <script>
    (function() {
        var myConfig = {
            height: '180px',
            width: '100%',
            animate: true,
            dompath: true,
            focusAtStart: true
        };
        myEditor = new YAHOO.widget.Editor('editor', myConfig);
    
        YAHOO.util.Event.onAvailable('iconMenu', function() {
            YAHOO.util.Event.on('iconMenu', 'click', function(ev) {
                var tar = YAHOO.util.Event.getTarget(ev);
                if (tar.tagName.toLowerCase() == 'img') {
                    var img = tar.getAttribute('src', 2);
                    var _button = this.toolbar.getButtonByValue('inserticon');
                    _button._menu.hide();
                    this.toolbar.fireEvent('inserticonClick', { type: 'inserticonClick', icon: img });
                }
                YAHOO.util.Event.stopEvent(ev);
            }, myEditor, true);
        });
    
    //Inside an event handler after the Editor is rendered
    YAHOO.util.Event.on('button', 'click', function() {
        //Put the HTML back into the text area
        myEditor.saveHTML();
    
        //The var html will now have the contents of the textarea
        var html = myEditor.get('element').value;
    });
    
        myEditor.on('toolbarLoaded', function() { 
           
            var imgConfig = {
                type: 'push', label: 'Insert Icon', value: 'inserticon',
                menu: function() {
                    var menu = new YAHOO.widget.Overlay('inserticon', {
                        width: '165px',
                        height: '210px',
                        visible: false
                    });
                    var str = '';
                    for (var a = 0; a < 1; a++) {
                        for (var i = 1; i < 54; i++) {
                            str += '<a href="#"><img src="../images/icons/smile/suit' + i + '.gif" class="imgIc"></a>';
                        }
                    }
                    menu.setBody('<div id="iconMenu">' + str + '</div>');
                    menu.beforeShowEvent.subscribe(function() {
                        menu.cfg.setProperty('context', [
                            myEditor.toolbar.getButtonByValue('inserticon').get('element'),
                            'tl', 'bl'
                        ]);
                    });            
                    menu.render(document.body);
                    menu.element.style.visibility = 'hidden';
                    return menu;
                }()
            };
            myEditor.toolbar.addButtonToGroup(imgConfig, 'insertitem');
    
            myEditor.toolbar.on('inserticonClick', function(ev) {
                var icon = '';
                this._focusWindow();
                if (ev.icon) {
                    icon = ev.icon;
                }
                this.execCommand('inserthtml', '<img src="' + icon + '" border="0">');
            }, myEditor, true);
    
        });
    myEditor._defaultToolbar.titlebar = false;
        myEditor.render();
    })();
    </script>
    <?php include"../footer.php";?>
    </body>
    </html>
    

     

    the textarea $editor isn't submitting into the database at all and when i echo the return when i click the submit button the variable is completely empty even though i see no error or mistake can anyone see why this isn;t working.

  3. i'm struggling to find a way to take a text field from a database and delete a certain word from the record and then to update it again. for example if the text field was

     

    "hello tester please delete me tester, tester tester"

     

    i wished to delete all the words tester then update the text field to the new record.

     

    how could i do this?

     

    thanks for reading

  4.  

     

    my full code is

     

    <?php
    session_start();
    $username=$_SESSION['username'];
    include_once"../includes/db_connect.php";
    $cat=$_GET['cat'];
    ?>
    <!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=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <?php 
    $query=mysql_query("SELECT products.name AS name, products.price AS price, addtionalCategories.productID AS productID FROM products, addtionalCategories WHERE products.category='1' AND products.id = addtionalCategories.productID");
    while($fetch=mysql_fetch_object($query)){
    echo"$fetch->name";
    }
    ?>
    </body>
    </html>
    

     

    i'm trying to display all my products by name from my mysql database however i two tables one which is products which contains the master category in a field called category and another table which is called additionalCategories which contains a field called productID which is the same as a record in the products table i use the id field in the products table and inset into additonalCategories to allow myself to add products to more than one categories however when i try join the too so i can display all products in the category from the products table and all products from additionalCategories.

     

    however it isn't displaying anything. :(

     

     

  5. silly newbie mistake

     

    <?php 
    $query=mysql_query("SELECT products.name AS name, products.price AS price, addtionalCategories.productID AS productID FROM products, addtionalCategories WHERE category='1' AND products.id = addtionalCategories.productID");
    while($fetch=mysql_fetch_object($query)){
    echo"$fetch->name";
    }
    ?>
    

     

    however it still echos only the following id departmentID categoryID subcategoryID productID

  6. Hi there i have a big issues which is starting to cause me lots of stress. I have two tables one which is products and contains the following below and the other which is additionalCategories which the contains is also below.

     

    products

     

    id

    name

    image1 

    image2

    image3

    image4 

    image5

    description

    department

    category

    subcategory 

    Price

     

    additonalCategories

     

            id 

    departmentID 

    categoryID 

    subcategoryID

    productID

     

    i have made a products upload script to my site where i can add products too it saves the category and subcategory id's in the fields above then if i wish to add the product to additional categories i do so and again this adds all the data to the addiotnalCategories table.

     

    however i can seems to be able to display this on the view products page i tried the below code but get no luck

     

    <?php
    session_start();
    $username=$_SESSION['username'];
    include_once"../includes/db_connect.php";
    $cat=$_GET['cat'];
    ?>
    <!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=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <?php 
    $query("SELECT products.name AS name, products.price AS price, addtionalCategories.productID AS productID FROM products, addtionalCategories WHERE category='$cat' AND products.id = addtionalCategories.productID");
    while($fetch=mysql_fetch_object($query)){
    echo"$fetch->name";
    }
    ?>
    </body>
    </html>
    

     

    i need a way in which on the page it check the category id then finds all the products that are saved in the additionalCategories table then to find the data saved in the products table such as the name and price etc

     

    please any help will be appreciated thank you for reading

     

  7. would this work to find all jpg and all png and gifs with a certain directory?

     

    $dir = opendir( "pics" );
    $pics = array();
    while( $fname = readdir( $dir ) )
    {
      if ( preg_match( "/[.]jpg$/","/[.]gif$/","/[.]png$/", $fname ) )
        $pics []= $fname;
    }
    closedir( $dir );
    

  8. I have have acquired this script for cropping images however it only crops the image upon upload to save to my thumbnails directory. i need it tooo do this three times at third different sizes

     

    i need it too allow me to do the main image at h:420 w:300 and save it too ../images/products/

    then the second needs to be a medium image at h:252 w:180 and save it too ../images/products/medium

    then the third needs to be the thumbnail which is the code below at h:102 w:72 and save it too ../images/products/thumbnails/

     

    the code below works perfectly fine to create a quailty thumbnail at the right size and it saves it in the right directory but when i try to clone the code to do the above two it's not allowing me to use some of the same functions again.

     

    how can this be done?

     

    //define a maxim size for the uploaded images in Kb
    define ("MAX_SIZE","300"); 
    
    //This function reads the extension of the file. It is used to determine if the file  is an image by checking the extension.
    function getExtension($str) {
             $i = strrpos($str,".");
             if (!$i) { return ""; }
             $l = strlen($str) - $i;
             $ext = substr($str,$i+1,$l);
             return $ext;
    }
    //get the extension of the file in a lower case format
           $filename = stripslashes($_FILES['Image1']['name']);
      		$extension = getExtension($filename);
    		$extension = strtolower($extension);
    
      define( 'DESIRED_IMAGE_WIDTH', 150 );
      define( 'DESIRED_IMAGE_HEIGHT', 150 );
    
      $source_path = $_FILES[ 'Image1' ][ 'tmp_name' ];
      
    //get the extension of the file and check if it is support or not
    if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
    		{die('This file type is not support, you may only use PNG GIF and JPG files.');}
    
    $size=filesize($_FILES['image']['tmp_name']);
    
    if ($size > MAX_SIZE*1024){ die('The File Size Is Too Large!'); }
    
      //
      // Add file validation code here
      //
    
      list( $source_width, $source_height, $source_type ) = getimagesize( $source_path );
    
      switch ( $source_type )
      {
        case IMAGETYPE_GIF:
          $source_gdim = imagecreatefromgif( $source_path );
          break;
    
        case IMAGETYPE_JPEG:
          $source_gdim = imagecreatefromjpeg( $source_path );
          break;
    
        case IMAGETYPE_PNG:
          $source_gdim = imagecreatefrompng( $source_path );
          break;
      }
    
      $source_aspect_ratio = $source_width / $source_height;
      $desired_aspect_ratio = DESIRED_IMAGE_WIDTH / DESIRED_IMAGE_HEIGHT;
    
      if ( $source_aspect_ratio > $desired_aspect_ratio )
      {
        //
        // Triggered when source image is wider
        //
        $temp_height = DESIRED_IMAGE_HEIGHT;
        $temp_width = ( int ) ( DESIRED_IMAGE_HEIGHT * $source_aspect_ratio );
      }
      else
      {
        //
        // Triggered otherwise (i.e. source image is similar or taller)
        //
        $temp_width = DESIRED_IMAGE_WIDTH;
        $temp_height = ( int ) ( DESIRED_IMAGE_WIDTH / $source_aspect_ratio );
      }
    
      //
      // Resize the image into a temporary GD image
      //
    
      $temp_gdim = imagecreatetruecolor( $temp_width, $temp_height );
      imagecopyresampled(
        $temp_gdim,
        $source_gdim,
        0, 0,
        0, 0,
        $temp_width, $temp_height,
        $source_width, $source_height
      );
    
      //
      // Copy cropped region from temporary image into the desired GD image
      //
    
      $x0 = ( $temp_width - DESIRED_IMAGE_WIDTH ) / 2;
      $y0 = ( $temp_height - DESIRED_IMAGE_HEIGHT ) / 2;
    
      $desired_gdim = imagecreatetruecolor( DESIRED_IMAGE_WIDTH, DESIRED_IMAGE_HEIGHT );
      imagecopy(
        $desired_gdim,
        $temp_gdim,
        0, 0,
        $x0, $y0,
        DESIRED_IMAGE_WIDTH, DESIRED_IMAGE_HEIGHT
      );
    
      //
      // Render the image
      // Alternatively, you can save the image in file-system or database
      //
    
      if($extension == "jpg"){imagejpeg( $desired_gdim, '../images/products/thumbnails/test.jpg' );}
      if($extension == "gif"){imagegif( $desired_gdim, '../images/products/thumbnails/test.gif' );}
      if($extension == "png"){imagepng( $desired_gdim, '../images/products/thumbnails/test.png' );}
    
      //
      // Add clean-up code here
      //
    

     

    thanks for reading.

  9. Hi, how can i make a simple bit of code that will allow me to have three jump menus,

     

    the first will be department where you select a department the second will be category then the three will be subcategory

     

    when i select the department i want it to change the second jumpmenu to display only categories in that department and when i select the category i want it to only display subcategories on the three jump menu in that category.

     

    thank you for reading.

×
×
  • 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.