Jump to content

sungpeng

Members
  • Posts

    290
  • Joined

  • Last visited

Posts posted by sungpeng

  1. <table width"500"><tr><td width"500">
    <?php $selectquerys = "SELECT * FROM users where llid='$llid'";
    $results = mysql_query($selectquerys);
    $rows = mysql_fetch_array($results);
    echo "$rows[description]<br/>"; ?></td></tr></table>

     

    Have some problem with table width. If like say my $rows[description] length is longer than table length width="500", I need it to go to the next row. Currently it will auto increase the table width to the $rows[description] length? why is that so? Can anyone help pls?

    ???

  2. Name of the below save as header.php               

        
    
    
    
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gbk">
    
    
    
    
    <script type="text/javascript" src="dropdown.js"></script>
    
    <style type="text/css">
    
    body { font-size: 0.7em; }
    h3   { font-size: 1.6em; margin: 0px; }
    
    a.sample_attach, a.sample_attach:visited, div.sample_attach
    {
      display: block;
      width:   100px;
    
      border:  1px solid black;
      padding: 2px 5px;
    
      background: #FFFFEE;
    
      text-decoration: none;
      font-family: Verdana, Sans-Sherif;
      font-weight: 900;
      font-size: 1.0em;
      color:   #008000;
    }
    
    a.sample_attach, a.sample_attach:visited { border-bottom: none; }
    div#sample_attach_menu_child             { border-bottom: 1px solid black; }
    
    form.sample_attach
    {
      position: absolute;
      visibility: hidden;
    
      border:  1px solid black;
      padding: 0px 5px 2px 5px;
    
      background: #FFFFEE;
    }
    
    form.sample_attach b
    {
      font-family: Verdana, Sans-Sherif;
      font-weight: 900;
      font-size: 1.1em;
    }
    
    input.sample_attach { margin: 1px 0px; width: 170px; }
    
    </style>
    
    
    </head>
    
    <body>
    
    <br /><br />
    
    <div id="sample_attach_menu_parent" class="sample_attach">Main Menu</div>
    <div id="sample_attach_menu_child">
    <a class="sample_attach" href="javascript:alert('Item 1');">Item 1</a>
    <a class="sample_attach" href="javascript:alert('Item 2');">Item 2</a>
    <a class="sample_attach" href="javascript:alert('Item 3');">Item 3</a>
    </div>
    
    <script type="text/javascript">
    at_attach("sample_attach_menu_parent", "sample_attach_menu_child", "hover", "y", "pointer");
    </script>
    
    </body>
    
    </html>    

                     

     

     

     

    Save below as dropdown.js

    
    
    function at_show_aux(parent, child)
    {
      var p = document.getElementById(parent);
      var c = document.getElementById(child );
    
      var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
      var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;
    
      for (; p; p = p.offsetParent)
      {
        top  += p.offsetTop;
        left += p.offsetLeft;
      }
    
      c.style.position   = "absolute";
      c.style.top        = top +'px';
      c.style.left       = left+'px';
      c.style.visibility = "visible";
    }
    
    // ***** at_show *****
    
    function at_show()
    {
      var p = document.getElementById(this["at_parent"]);
      var c = document.getElementById(this["at_child" ]);
    
      at_show_aux(p.id, c.id);
      clearTimeout(c["at_timeout"]);
    }
    
    // ***** at_hide *****
    
    function at_hide()
    {
      var p = document.getElementById(this["at_parent"]);
      var c = document.getElementById(this["at_child" ]);
    
      c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
    }
    
    // ***** at_click *****
    
    function at_click()
    {
      var p = document.getElementById(this["at_parent"]);
      var c = document.getElementById(this["at_child" ]);
    
      if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
      return false;
    }
    
    // ***** at_attach *****
    
    // PARAMETERS:
    // parent   - id of the parent html element
    // child    - id of the child  html element that should be droped down
    // showtype - "click" = drop down child html element on mouse click
    //            "hover" = drop down child html element on mouse over
    // position - "x" = display the child html element to the right
    //            "y" = display the child html element below
    // cursor   - omit to use default cursor or specify CSS cursor name
    
    function at_attach(parent, child, showtype, position, cursor)
    {
      var p = document.getElementById(parent);
      var c = document.getElementById(child);
    
      p["at_parent"]     = p.id;
      c["at_parent"]     = p.id;
      p["at_child"]      = c.id;
      c["at_child"]      = c.id;
      p["at_position"]   = position;
      c["at_position"]   = position;
    
      c.style.position   = "absolute";
      c.style.visibility = "hidden";
    
      if (cursor != undefined) p.style.cursor = cursor;
    
      switch (showtype)
      {
        case "click":
          p.onclick     = at_click;
          p.onmouseout  = at_hide;
          c.onmouseover = at_show;
          c.onmouseout  = at_hide;
          break;
        case "hover":
          p.onmouseover = at_show;
          p.onmouseout  = at_hide;
          c.onmouseover = at_show;
          c.onmouseout  = at_hide;
          break;
      }
    }
    

     

    When you just view the header.php page, the dropdown menu work nicely. Question is when you use

    include ("".$_SERVER['DOCUMENT_ROOT']."/housing/includes/header.php");

    to call out the header, the javascript won't work anymore?

  3. Hi check did anyone encounter this problem?  I put javascript dropdown menu on php header. Then I use "include" to call out the header. PHP doesn't read the javascript in the header. When I just view the header page itself, there is no problem. Why is that so?

  4. $sql = "SELECT * FROM listings WHERE address LIKE '%$address%' AND type LIKE '%$type%' AND price LIKE '%$price%' ORDER BY listdate LIMIT $offset, $rowsperpage"; 

     

    sql = "SELECT * FROM users WHERE specialise1 LIKE '%$specialise1%' OR specialise2 LIKE '%$specialise1%' OR specialise3 LIKE '%$specialise1%' ORDER BY listdate LIMIT $offset, $rowsperpage" or die(mysql_error()); 

     

     

    The above 2 codes is working fine. But once "or" "or" "and" conbined together, the "and" part is not working anymore?

     

     

  5. $sql = "SELECT * FROM users WHERE specialise1 LIKE '%$specialise1%' OR specialise2 LIKE '%$specialise1%' OR specialise3 LIKE '%$specialise1%' AND status='on' ORDER BY listdate LIMIT $offset, $rowsperpage" or die(mysql_error());   

     

    Hi jack it still display the record although my status is 'off'. Not 'on'. By right it shouldn't display anything. It did not show any error.

  6. $sql = "SELECT * FROM users WHERE specialise1 LIKE '%$specialise1%' OR specialise2 LIKE '%$specialise1%' OR specialise3 LIKE '%$specialise1%' AND status='on' ORDER BY listdate LIMIT $offset, $rowsperpage";   

     

    hi above the  status='on' function is not working, status either "off" or "on" it will display, is there any mistake in the above query? pls help.. Thk

  7. <?php
    header('content-type: image/jpeg');
    $watermark = imagecreatefrompng('hello.png');  
    
    $watermark_width = imagesx($watermark);  
    $watermark_height = imagesy($watermark);  
    $image = imagecreatetruecolor($watermark_width, $watermark_height);  
    $image = imagecreatefromjpeg('notebook.jpg');  
    $size = getimagesize('notebook.jpg');  
    $dest_x = $size[0] - $watermark_width - 5;  
    $dest_y = $size[1] - $watermark_height - 5;  
    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);  
    imagejpeg($image, "hihi.jpg");  
    
    
    ?>

    I need the hello.png to be the watermark for notebook.jpg. The code merge both photo together, but the hello.png appear to be total black. Can I know why is that so?

  8. <?php
    session_start();
    include ("".$_SERVER['DOCUMENT_ROOT']."/config.php");
    $query=mysql_query("select * from stats where id='1'" );
    $row=mysql_fetch_array($query);
    
    $count="$row[counter]";
    $_SESSION[$count]=$_GET[rid];
    
    ?><html>
    <body><?php
    
    
    while($index<=10000)
      {
    $arr =$_SESSION[$index];
    echo "$arr";  
    
      $index++;
      }
    
    
    ?></body>
    </html>

     

    row[counter] is a counter that will add one once you click on this page, it is within 10000. I don't see any problem in above code but why it cannot work. It time to use database.

  9. <?php
    session_start();
    $indexnumber=$_GET[rid];
    $arr1 = array("somearray" => array($indexnumber => $indexnumber)); 
    $arr2=$_SESSION['views'];
    $arr=array_merge($arr2, $arr1);
    
    $_SESSION['views']=$arr;
    
    ?><html>
    <body><?php
    $arr=$_SESSION['views'];
    
    foreach ($arr['somearray'] as $key => $val) {
        echo "{$key} => {$val}<br />";
    }
    
    
    ?></body>
    </html>

     

    It's seen possible to use array merge?? I have seen people use session to store many id and later display all "shortlisted" in one page but I just cannot figure out how?

  10. <?php
    session_start();
    $indexnumber=$_GET[rid];
    $arr1 = array("somearray" => array($indexnumber => $indexnumber)); 
    $arr2=$_SESSION['views'];
    $arr=array_combine($arr2, $arr1);
    $_SESSION['views']=$arr;
    
    ?><html>
    <body><?php
    $arr=$_SESSION['views'];
    
    foreach ($arr['somearray'] as $key => $val) {
        echo "{$key} => {$val}<br />";
    }
    
    
    ?></body>
    </html>

     

    Just checking why about code cannot work?  I still think is possible to use session array to store all indexnumber passed.

  11. How to make it not overwrite the other ones.

    intended result

    $arr = array("somearray" => array(5 => 5, 9 => 9, 42 => 42));

    It will store all variable passed.

     

    Amend

    Need to store many products in session array then check out, view all products without the person who is using it log in to the account.

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