Jump to content

gurroa

Members
  • Posts

    87
  • Joined

  • Last visited

    Never

Posts posted by gurroa

  1. To display image you will have to create new php script that will accept pid and output only the image.

    This new script vary from way you are saving image data into the dbase.

    I would save images as base64_encode()d raw data.

     

    And as long as you store imgdata into your message table don't select this field when you don't need it.

    Otherwise imgdata is retrieved from your db too.

    SELECT pid, usrname_email, userID, userstatus, full_message FROM $table_name ORDER BY userstatus ASC
    

     

    <?php //viewimage.php
    
      Header("Pragma: no-cache");
      Header("Cache-Control: no-cache");
      Header("Expires: ".GMDate("D, d M Y H:i:s")." GMT");
    
      if (isset($_GET['pid']) && is_int($_GET['pid'])) {
        mysql_connect(.... // connection
      
        $res = mysql_query("select imgdata from message where pid = ".$_GET['pid']);
        if ($res) {
          $row = mysql_fetch_assoc($res);
          
          // This is only if you are storing jpeg images
          Header("Content-type: image/jpeg");
    
          Header("Content-Disposition: inline; filename=img".$_GET['pid'].".jpeg");
          
          echo base64_decode($row['imgdata']);
        }
      }
    ?>
    

     

    To put such image into your messages script

    while($row = mysql_fetch_array($result))
    {
          $display_block .= "
           
       <tr><td>----------------------------------------
            <font color=blue><p>User/Email:".$row['usrname_email']." ".$row['userID']."</font>
            <img src=\"viewimage.php?pid=".$row['pid']."\" align=left ...>
            ----------------------------------------<p>
            User Status:$row['userstatus']<p>Date:$row[date]<p>Full Message:$row['full_message']
       </td>
       </tr>";
    }
    

     

  2. Sorry to miss all the others...

    $storedata = mysql_query('INSERT INTO liam_database(Username, Password, Email,Favourite Sport,IP,date);  
                                         VALUES ( "'.addslashes($user).'",   
                                                  "'.md5($pass).'",
                                                  "'.addslashes($email).'",
                                                  "'.addslashes($sport).'",
                                                  "'.addslashes($IP).'",
                                                  "'.addslashes($date).'")') or die(mysql_error());
    

    Missing , in values set and ) at the end.

  3. You should mention...

     

      $year = trim($_POST['year']);
      $datefrom = '';
      if (!empty($year)) {
        $ardate = array($year);
        if (strpos($year, '.') !== false) 
          $ardate = Explode('.', $year);
        else
        if (strpos($year, '-') !== false)
          $ardate = Explode('-', $year);
          
        $c = count($ardate);
        if ($c == 3) {
          $datefrom = sprintf("%04d-%02d-%02d", trim($ardate[2]), trim($ardate[1]), trim($ardate[0]) );
          $dateto   = $datefrom;
        } 
        elseif ($c == 2) {
          $datefrom = sprintf('%04d-%02d-01', trim($ardate[1]), trim($ardate[0]) );
          $dateto   = Date("Y-m-d", strtotime("+1 month -1 day", strtotime(sprintf('%04d-%02d-01', trim($ardate[1]), trim($ardate[0])) )) );
        } 
        elseif (is_integer($year)) {
          $datefrom = sprintf('%04d-01-01', $year);
          $dateto   = sprintf('%04d-12-31', $year);
        }
      } 
      
      if (!empty($datefrom)) {
        $sql = "SELECT * FROM Temper WHERE Date >= '{$datefrom}' and Date <= '{$dateto}'";
        ....
      }
    

  4. If you don't want to wait for reply..

    http://www.php.net/manual/en/index.php

     

        $prod = array();
        // creates new empty array
    
        reset($arProd);
        // set array position to the first element
    
        while(list(,$row) = each($arProd)) {
          // this will take element from $arProd array on current position and push position to the next element
    
          $prod[] = $row['Name'];
          // add value from the $row array under the key 'Name' to the $prod array
    
        } 
        echo Implode(", ", $prod);
        // print out all values in the $prod array split by ', ' string
    

     

    You can't use your while statement cause it will be an infinitive loop

     

    To print out data as you've mentioned use my previous construct with this output

    if (count($arProductsByItem) > 0) {
      reset($arProductsByItem);
      while(list($Item,$arProd) = each($arProductsByItem)) {
        echo 'Item: '.$Item.'<br />';
    
        reset($arProd);
        while(list(,$row) = each($arProd)) {
          echo 'product'.$i.' '.$row['Name'].' : '.$row['PriceRetail'].'<br />';
          ++$i;
        }
        echo '<br />';
      }
    }
    

  5. <?php
    $arProductsByItem = array();
    if ($numProduct > 0 ) {
      $i = 0;
      while ($row = dbFetchAssoc($result)) {
        $arProductsByItem[$row['ItemName']] = $row;
      } 	
    }
    // example of later output
    if (count($arProductsByItem) > 0) {
      reset($arProductsByItem);
      while(list($Item,$arProd) = each($arProductsByItem)) {
        echo 'Item: '.$Item.' - Products: ';
    
        $prod = array();
        reset($arProd);
        while(list(,$row) = each($arProd)) {
          $prod[] = $row['Name'];
        } 
        echo Implode(", ", $prod);
      }
    }
    ?>
    

  6. Your multi_file table consist at least of fields

    mult_id

    synopsis

    file_picture

    file_name

    file_description

    file_link

     

    first row for bleach is

    mult_id => '1', synopsis => 'Ichigo Kurosaki ... SEE anime', file_picture => 'http://www.mu-anime.com/bleach.jpg',

    file_name => 'Bleach Episode 1', file_description => 'The day I became a shinigami', file_link => 'http://www.megaupload.com/?d=IASUWFNF'

     

    second and others has only filled: mult_id, file_name, file_description, file_link

     

    You should change your dbase. My opinion is to split your table into two

     

    multi_file - mult_id, synopsis, file_picture

    sub_files - mult_id, file_picture, file_name, file_description, file_link

     

  7. Make sure you're not missing file_picture values in the db.

    while($myarray = mysql_fetch_array($sql)){
       // Build your formatted results here.
       echo $myarray['synopsis']."<br /><br />";
       if (!empty($myarray['file_picture'])) {
         echo "<img src='" .$myarray['file_picture']. "' align=\"right\" alt=\"\" />";
       }
       echo "<font color=\"#3399FF\">Episode:</font>" . " " .$myarray['file_name']."<br />";
       echo "<font color=\"#3399FF\">Title:</font>" . " " .$myarray['file_description']."<br />";
       echo "<font color=\"#3399FF\">Link:</font>" ." ". "<a href=\"".$myarray['file_link']. "\" target=\"_blank\">Click Here To Download</a>";
    }
    

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