Jump to content

dc_jt

Members
  • Posts

    290
  • Joined

  • Last visited

    Never

Posts posted by dc_jt

  1. Hi I have a table containg name, description, url which contains many records

     

    When I submit a new form, I want it to check the url fields in the table and check it against what I have posted. Therefore something like

     

    $check_table = function here to get all urls

     

    if($_POST['url'] == $check_table) {

    return false;

    } else {

    return true

    }

     

    However, how do I get all the urls and get it to check each one?

     

    Thanks

  2. Hi

     

    Ive got the following which is meant to delte the may2007 folder if there is nothing inside of it. The only types of file it holds is .doc and .pdf. When I put one of each in there and I delete the .pdf, then this deletes just that and nothing else which is correct because there is still another document (the .doc one) in the folder.

     

    However, if I put both in and I delete the .doc one first, then this deletes the whole folder (may2007) when it shouldnt because there is another file in there (the .pdf one).

     

    Hope that wasnt too confusing and someone can help. Thanks

     

    public function RemoveDownload($iNewsId)
    
    {
    	$oDownload = $this->GetObject($iNewsId);
    
    	if ($oDownload->download)
    	{
    		unlink($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_DOWNLOAD.$oDownload->download_path.'/'.$oDownload->download);
    
    		$files = glob($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_DOWNLOAD.$oDownload->download_path.'/{*.doc, *.pdf, *.DOC, *.PDF}', GLOB_BRACE);//Makes sure that it contains no Image
    		if(count($files) < 1)
    		{
    			$oDeleteFolder = $this->removeFolder($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_DOWNLOAD.$oDownload->download_path);
    		}
    	}
    
    	$sSql = "UPDATE $this->sTableName SET download = '', download_path = '' WHERE $this->sPrimaryKey = '$iNewsId' ";
    
    	return mysql_query($sSql, $this->oDb->GetConnection());
    }

  3. Hi Ive got the following drop down menu and I want to perform an action every time someone uses the dropdown. How Can I determine when it has been used? Normally I would pass in a mode but because its GET, I cant and if i change it to POST, it doesnt work how I want it to?

     

    Thanks

     

    <select name="iCat_Id" onchange="CatChange.submit()">
    <option value="0">-- All Offers --</option>
    
    <?php 
    	//Get categories for this site
    $rCategories = $oTblCategories->GetCategories();
    
    while ($oCategories = mysql_fetch_object($rCategories))
    	{?>
    <option value="<?=$oCategories->category_id?>"<?=($iCatId == $oCategories->category_id)?' selected="selected"':''?>>
    <?=$oCategories->category ?></option>
    
       <?php } ?>	
    </select>
    </form>

  4. Thanks a lot, this worked, however January is not included for some reason??

     

    Hi I have the following code which is a drop down containing a month and a year.

     

    At the moment, the months are displayed 1,2,3,4 etc, however I want them to be displayed as Jan, Feb, Mar etc but the values to remain 01, 02, 03 etc.

     

    <form name="date" action="<?=$_SERVER['PHP_SELF']?>?sMode=ChangeFilter" method="POST" class="sort">
    <label>Date:</label>
    <select name="datem" id="datem">
    <?php
    
       $iCurMonth = ('5');
      for ($i=1;$i<=12;$i++)
      { ?>
      <option <?=((isset($aFilterParts['datem']) && $i==$aFilterParts['datem']) || (!isset($aFilterParts['datem']) && $i==$iCurMonth))?' selected="selected"':''?>><?=$i?></option>
      <?php } ?>
    
    </select>
    <select name="datey" id="datey">
    <?php
       $iCurYear = ('2007');
      for ($i=2007;$i<=2009;$i++)
      { ?>
      <option <?=((isset($aFilterParts['datey']) && $i==$aFilterParts['datey']) || (!isset($aFilterParts['datey']) && $i==$iCurYear))?' selected="selected"':''?>><?=$i?></option>
      <?php } ?>
    </select>
    <input type="Submit" name="submit" value="Submit"/>
    </form>

     

    Thanks

  5. Hi I have the following code which is a drop down containing a month and a year.

     

    At the moment, the months are displayed 1,2,3,4 etc, however I want them to be displayed as Jan, Feb, Mar etc but the values to remain 01, 02, 03 etc.

     

    <form name="date" action="<?=$_SERVER['PHP_SELF']?>?sMode=ChangeFilter" method="POST" class="sort">
    <label>Date:</label>
    <select name="datem" id="datem">
    <?php
    
       $iCurMonth = ('5');
      for ($i=1;$i<=12;$i++)
      { ?>
      <option <?=((isset($aFilterParts['datem']) && $i==$aFilterParts['datem']) || (!isset($aFilterParts['datem']) && $i==$iCurMonth))?' selected="selected"':''?>><?=$i?></option>
      <?php } ?>
    
    </select>
    <select name="datey" id="datey">
    <?php
       $iCurYear = ('2007');
      for ($i=2007;$i<=2009;$i++)
      { ?>
      <option <?=((isset($aFilterParts['datey']) && $i==$aFilterParts['datey']) || (!isset($aFilterParts['datey']) && $i==$iCurYear))?' selected="selected"':''?>><?=$i?></option>
      <?php } ?>
    </select>
    <input type="Submit" name="submit" value="Submit"/>
    </form>

     

    Thanks

  6. Hi

     

    I tried both of the above, but not getting any joy.

     

    I want to remove an image (which i have done), however I want it to check if there is anything else left in this folder and if not, then for the file to be deleted. This is the remove function I have:

     

    public function RemoveImage1($iNewsId)
    
    {
    	$oObj = $this->GetObject($iNewsId);
    
    	if ($oObj->image1)
    	{
    
    		unlink($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_NEWS_LARGE.'/'.$oObj->image_path.'/'.$oObj->image1);
    		unlink($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_NEWS_THUMBNAILS.'/'.$oObj->image_path.'/'.$oObj->image1);
    
                            //Think I need something here to delete the folder             //$_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_NEWS_LARGE.'/'.$oObj->image_path
    
    		$sSql = "UPDATE $this->sTableName SET image1 = '', image_path = '' WHERE $this->sPrimaryKey = '$iNewsId' ";
    		return mysql_query($sSql, $this->oDb->GetConnection());
    	}
    
    	return true;
    }

  7. Hi

     

    I have a table like the following:

     

    offer_id    name      ordering

    1            test              5

    2            test 2          4

    3            test 3          3

    4            test 6          2

    5            test 5          1

     

    As I enter more, they go to the top so the next one would have ordering 6.

     

    How do I find the first four? ( test, test2, test3 and test 4) I.e The latest ones added?

     

    Thanks

  8. Hi

     

    Ive got an offers table which contains name, category_id

     

    I want to display all offers, however the first page will only display four offers (one of each category).

     

    My query is as follows so how do I do this part?

     

    Thanks

     

    public function GetAll($iStart = 0, $iLimit = 0, $iCategoryId)
    {
    	$date = date("Y-m-d");
    
    	$sSql = "SELECT offer_id, title, description, short_description, date_posted,
    		start_date, end_date, image1, image_path, download, download_path, category_id, link, ordering, display, featured
    	FROM $this->sTableName 
    	WHERE display = 1 &&
    	featured = 0 &&
    	start_date <= '$date' &&
    	end_date >= '$date'";
    
    	$sSql .= "ORDER BY ordering DESC";
    
    	$iStart = (int) $iStart;
    	$iLimit = (int) $iLimit;
    
    	if ($iStart >= 0 && $iLimit > 0)
    	{
    		$sSql .= " LIMIT $iStart, $iLimit";
    	}
    
    	return mysql_query($sSql, $this->oDb->GetConnection());
    }

  9. Hi

     

    I have a table which contains special offers starting from a certain date and ending at another date.

     

    Therefore would I just do

     

    $date = date("Y-m-d H:i:s ");

     

    SELECT * from Tablename

    WHERE start_date <= '$date' &&

    end_date >= '$date'

     

    Is this correct?

     

    Thanks

  10. Hi I have the following code which contains two arrays and a password function.

     

    I want to generate a different password for each element in the array, at the moment it is just giving everyone the same one?

     

    Here is an example:

     

    $name = array("ZEINA MORRIS", "LEANNE DENNIS", "NICKY BROPHY");
    $employee_number = array("A393", "A394", "A493");
    $password = $oTblLeads->generate_password(4);
    
    for ($i=0; $i < count($name); $i++){
    
       mysql_query("INSERT INTO cms_users (name, employee_number, pin_code) VALUES ('$name[$i]', '$employee_number[$i]', '$password')")
       or die(mysql_error());

  11. I posted this in sql forum but there is no one in there!

     

    Hi I have a very long list for example john, david, james, john.

     

    I want to add these names into my table which containts user_id, name, password

     

    Obviously I want these in the name field. How would I do this?

     

    Thanks

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