Jump to content

Akira

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Posts posted by Akira

  1. Okay, so here is the deal.

     

    Have a table which stores image as blob files. Now i want to read the image width and height directly from the blob field.

    Is this possible and if yes, how?

     

    Things i tried so far;

    list($size[0],$size[1],$type, $attr) = getimagesize('image.php?i=26ddd45b02859e836d13d4b9fde34281');      
    print_r($size);

     

    $img = 'image.php?i=26ddd45b02859e836d13d4b9fde34281';
    echo imagesy($img);

     

    image.php grabs the image from DB and show's it with header("Content-type: image/jpg");   

    It works for just showing the images with the <img> tag.

     

    Any ideas of help would be great!

  2. Hey freakz,

     

    Have a small issue which i just cant resolve, i want to build a recursive multidimensional array.  I made a function which can read on level depts but just can't get the info in a multidimensional array.

     

    Hopefully somebody here has a anwser :)

     

    Function:

    <?php 
    function fillRights( $id, $level) { 
        $query = "SELECT id,nl,sub FROM tbl_rights WHERE sub = '".$id."';"; 
        $result = mysql_query( $query ); 
        
        while( $row = mysql_fetch_array( $result ) ) { 
            
            echo str_repeat('   ', $level).$row['nl'].'<br />'; 
            
            fillRights($row['id'],$level+1); 
            
        } 
    } 
    
    fillRights( '', 0 ); 
    ?> 

     

    Table to test

    DROP TABLE IF EXISTS `tbl_rights`; 
    CREATE TABLE `tbl_rights` ( 
      `id` int(11) NOT NULL auto_increment, 
      `nl` varchar(255) default NULL, 
      `en` varchar(255) default NULL, 
      `sub` varchar(11) default '', 
      PRIMARY KEY  (`id`) 
    ) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1; 
    
    
    INSERT INTO `tbl_rights` VALUES ('1', 'menu1', 'menu1', ''); 
    INSERT INTO `tbl_rights` VALUES ('2', 'menu2', 'menu2', ''); 
    INSERT INTO `tbl_rights` VALUES ('3', 'menu3', 'menu3', ''); 
    INSERT INTO `tbl_rights` VALUES ('4', 'submenu 1.1', 'submenu 1.1', '1'); 
    INSERT INTO `tbl_rights` VALUES ('5', 'submenu 2.1', 'submenu 2.1', '2'); 
    INSERT INTO `tbl_rights` VALUES ('6', 'submenu 1.2', 'submenu 1.2', '1'); 
    INSERT INTO `tbl_rights` VALUES ('7', 'submenu 2.2', 'submenu 2.2', '2'); 
    INSERT INTO `tbl_rights` VALUES ('8', 'submenu.3.1', 'submenu.3.1', '3'); 
    INSERT INTO `tbl_rights` VALUES ('9', 'menu4', 'menu4', ''); 
    INSERT INTO `tbl_rights` VALUES ('10', 'subsubmenu 1.2.1', 'subsubmenu 1.2.1', '6'); 
    INSERT INTO `tbl_rights` VALUES ('11', 'subsubmenu 1.2.2', 'subsubmenu 1.2.2', '6'); 
    INSERT INTO `tbl_rights` VALUES ('12', 'subsubsubmenu 1.2.1.1', 'subsubsubmenu 1.2.1.1', '10'); 

     

    My desired outcome:

    $rights['menu 1']['submenu 1.1']; 
    $rights['menu 1']['submenu 1.2']; 
    $rights['menu 1']['submenu 1.2']['subsubmenu 1.2.1']; 
    $rights['menu 1']['submenu 1.2']['subsubmenu 1.2.1']['subsubmenu 1.2.1.1']; 
    $rights['menu 2']; 
    $rights['menu 2']['submenu 2.1']; 
    $rights['menu 2']['submenu 2.2']; 
    $rights['menu 3']; 
    $rights['menu 3']['menu 3.1']; 
    $rights['menu 4'];

     

    Hope some one here has a clue :)

  3. Hey,

     

    I am building some sort of wiki page which has a lot of text on each page.

     

    Now multiple people are editing this wiki page, and if person A is editing I would like to send person B and C an email with the part of the text which has been edited.

     

    Any idea's on how to work this out?

     

    Regards, Maarten

     

  4. Ok, I know it must be some simple thing that I am doing wrong, but just can't find it :| maybe you guys have a clue :)

     

    I have a basic form with checkboxes, which i store in a field with PHP's function serialize().

    I view the checkboxes with the following function i wrote;

     

    function SelectCheckbox($id,$field){		
    
    $id = unserialize($id);
    
    $owner_q="SELECT * FROM $field ORDER BY name ASC";
    $owner_r= mysql_query($owner_q);
    while ($row = mysql_fetch_array($owner_r)) {  
    	$p_name = $row['name'];
    	$p_id = $row['id'];
    
    	for ($i=0; $i<count($id); $i++) {
    		$checked = (($p_id==$id[$i]) ? 'checked="checked"' : null);		
    	} 
    	print "<input type='checkbox' name='db[]' value='$p_id' $checked style='border:0px;'>$p_name <br>";			
    
    
    }
    } // end function

     

    So first i get the array with id's stored in the DB to match = $id= unserialize($id);.

    Then i do a while loop to get the names from the DB for the checkboxes + id's.

    And a for loop to check the id's from the array with the id's from the DB, when matched, it should echo the checkbox as checked.

     

    Now, only the last checked box is echo's as checked.

    What am i doing wrong here??

     

     

  5. I have a script which i use to download an excel file, with has generated content from a database.

    The download always worked perfect, but since the https was activated, it doens't download at all anymore...

     

    anyone know a solution for this?

  6. Ok, should be a stupid thing i'm missing but guys, please help.

     

    Working on a german site, which have loads of special chars like for example; ü.

     

    Now, I know, by inserting that kinda text in a DB with htmlentities() function, that fixes the problem.

    But now, in a language file, I have this:

     

    $LANG_SITE['link']['text']='<img src="/d4/_img/icon_link.gif"> Link zur offiziellen Website des Büros der';

     

    When i echo or print this array, the Büros part displays like:  B?er

    Using htmlentities() doens't work, cause it mixes up the html code.

     

    What is a other work arround?

     

    Thanks in advance for any responds!

       

  7. Hey,

     

    You can always view a sessions contents by using following;

     

    echo $_SESSION['myusername'];

     

    And use that to select data from that person form the DB; example;

     

    $name_q  = "SELECT * FROM users WHERE id='$_SESSION[myusername]'";
    $name_r = mysql_query($name_q) or die(mysql_error());

     

    So could also use;

     

    session_start();
    if(empty($_SESSION['myusername'])){
    header("location:index.php");
    }

     

     

  8. The strtotime() function doesn't like dates in the format dd/mm/yyyy, so you need to convert that date into a format it likes: mm/dd/yyyy:

    <?php
    list($d,$m,$y) = explode('/',$row['enddate']);
    $date = strftime("%d %B %Y",strtotime("$m/$d/$y"));
    ?>

     

    It would be much better if you stored the date in your DB as YYYY-MM-DD, then you could take advantage of the many date features of mysql.

     

    Ken

     

    Hey Ken,

     

    Thanks heaps for this!

    Added your code, and it works now :D

     

    Weird that this isn't well documented at php.net.

     

     

     

     

  9. When this code

    <?php
    $date = strftime("%d %B %Y",strtotime("16/06/2008"));
    echo $date;
    ?>

     

    outputs "01 January 1970 ", then I'd say you have problems

     

    hehe, nope, that code gives a nice output of 16 June 2008, like i said, no problems their :)

  10. Thanks for replying!

     

    $date = strftime("%d %B %Y",strtotime($row['enddate']));

     

    Still no output.

     

    And yes, at first i used;

    print $row['enddate'];

     

    but to give it a better look, I wanted to convert the date.

    So i'm sure that the $row['enddate'] is filled :)

  11. Hey all,

     

    I just don't get it.

    I have dates stored in my DB in the following format; 16/06/2008

     

    I want to convert them to; 16 June 2008.

     

    using following to do so;

    $date = strftime("%d %B %Y",strtotime("$row[enddate]"));

     

    Now, i just don't get it... cause the strotime function doens't make a timestamp.

    Output = empty.

     

    but when I use a normal string, like;

    $date = strftime("%d %B %Y",strtotime("16/06/2008"));

     

    No problems.

     

    What am i doing wrong here??

    Tried every combination;

    strtotime("$row[enddate]")
    strtotime($row['enddate'])
    strtotime($row[enddate])

     

    Running 2003 Server, IIS 6, PHP 5.2.

     

    Hope somebody has an anwser, out of ideas ^^

     

  12. Hey guys,

    Im trying to create a excel file from PHP and import this to Word.
    How can this be done??

    I've tried 2 different methods so far.
    1. genarating and XML file and saving it as Excel
    2. generating a full workbook, also with the help off XML

    A piece of the code

    [code]<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:html="http://www.w3.org/TR/REC-html40">
    <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
      <WindowHeight>11910</WindowHeight>
      <WindowWidth>15195</WindowWidth>
      <WindowTopX>480</WindowTopX>
      <WindowTopY>60</WindowTopY>
      <ProtectStructure>False</ProtectStructure>
      <ProtectWindows>False</ProtectWindows>
    </ExcelWorkbook>
    <Styles>
      <Style ss:ID="Default" ss:Name="Normal">
      <Alignment ss:Vertical="Bottom"/>
      <Borders/>
      <Font/>
      <Interior/>
      <NumberFormat/>
      <Protection/>
      </Style>
    </Styles>
    <Worksheet ss:Name="Blad1">
      <Table ss:ExpandedColumnCount="10" ss:ExpandedRowCount="<?=count($_POST['id'])?>" x:FullColumns="1"
      x:FullRows="1">
      <Column ss:Index="9" ss:Width="52.5"/>
      <Row>
        <Cell><Data ss:Type="String">voorletters</Data></Cell>
        <Cell><Data ss:Type="String">tussenvoegsel</Data></Cell>
        <Cell><Data ss:Type="String">achternaam</Data></Cell>
        <Cell><Data ss:Type="String">adres</Data></Cell>
        <Cell><Data ss:Type="String">huisnr</Data></Cell>
        <Cell><Data ss:Type="String">toevoeging</Data></Cell>
        <Cell><Data ss:Type="String">postcode</Data></Cell>
        <Cell><Data ss:Type="String">woonplaats</Data></Cell>
        <Cell><Data ss:Type="String">telefoon</Data></Cell>
        <Cell><Data ss:Type="String">e-mail</Data></Cell>
      </Row>[/code]

    But Word doenst see it as a legal document.

    Can someone help me with this, need to have this done by tonight 00.00 :|
  13. Hey guys! thnx for all the good reply's!

    Found that the following was the easiest to implent for me :)

    [code]// Since both datasets have the same number of rows
    $q1 = [Your first query]
    $q2 = [Your second query]
    while($r1 = mysql_fetch_array($q1))
    {
    $r2 = mysql_fetch_array($q2);
    echo "<tr><td>$r1[text]</td><td>$r2[text]</td></tr>";
    }[/code]

    thnx again for the great help! Works like a charm now :D
  14. Hey guys, thnx for the fast reply

    Don't mind the same queries, the 'doh' part is different, shoudl be $doh, cause the tabels are variable, sorry for that.

    so what i want is

    <table>
    <tr>
    <td> one databset ( one query with loop, both dataset have the same amount of rows) </td>
    </tr>
    <tr>
    <td> second dataset with different query </td>
    </tr>
    </table>

    Hope this clears a lot :)


  15. Hey people,

    Got bit weird question, googled it, but couldn't find anything about this subject.

    This is the isseu.
    I got 2 datasets in a while loop and want to insert them in the 2 seperate <td>'s

    So you would get something like this:
    [code]
    $en_q  = "SELECT * FROM doh WHERE view='4' ORDER BY sort ASC";
    $en_r = mysql_query($en_q) or die (mysql_error());
        while ($row = mysql_fetch_array($en_r)) {
            $menu_en=$row['text'];
             echo"<tr><td class='lang'>$menu_en</td>";
        }

    $en_q  = "SELECT * FROM doh WHERE view='4' ORDER BY sort ASC";
    $en_r = mysql_query($en_q) or die (mysql_error());
        while ($row = mysql_fetch_array($en_r)) {
            $menu_en=$row['text'];
             echo"<td class='lang'>$menu_en</td></tr>";
        }
    [/code]

    offcorse this doesn't work, so i guess i need to set a double while or somthing, like:


    [code]while ($row = mysql_fetch_array($en_r) && $lala = mysql_fetch_array($as_r)) [/code]

    Offcorse this doens't work either, but how can i solve this??

    Regards,
    Akira
  16. [!--quoteo(post=362212:date=Apr 6 2006, 03:48 PM:name=stefpretty)--][div class=\'quotetop\']QUOTE(stefpretty @ Apr 6 2006, 03:48 PM) [snapback]362212[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    ohye ALMOST THERE! i sorted the problem now except it registered but still came up with error message ill check itout tjankyou for all your help!
    [/quote]

    hehe okidokie no problem :)

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