showing image from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • matthewroth
    New Member
    • Feb 2008
    • 22

    #16
    Originally posted by ronverdonk
    I don't know from which of the two tables you select or what table indicates that he has an image I just wanted to point out that you had to do a new select in case the result of the first select was 0. .

    Ronald
    Think I am on the right track. my query works with mysql when i do the else select i get the user that does not have a picture, i just cant seem to figure out how to display it or could it be that my if statement is jacked up. this code is got me going in circles. i didnt think it would be that hard to say if user signs in this table1 and has photo in this table2 display picture from table2 else if user signs in table1 and has no image in table2 show default image. any ideas??

    Code:
    <?
    include_once('../sql_connect.php');
        $result = mysql_query("SELECT A.LastName, A.TimeOut, B.image, B.LastName  FROM nocsis A, image B WHERE A.LastName = B.LastName AND A.TimeOut IS NULL ORDER BY A.TimeIn DESC");
     
      if (mysql_num_rows($result) <> B.LastName ) {           
    
    
    
    {//begin of loop
     
                   //now print the results:
     
     
     
               echo '<table>'; // start the table.
     
     
     
    $_counter = -1;  // We start 'outside' the Matrix.  Unlike Neo.
    $_cols = 4; // 4 columns.  Of the Ionic variety.
    while($myrow = mysql_fetch_array($result)){ //get array of table.
       
        // Advance the counter and determine our 'position';
        
    $_pos = ( ++$_counter % $_cols );
     
        // Should we output a '<tr>'?
        
    if( $_pos === 0 )
        {
            echo '<tr>';
        }
     
    
    /// This will create link on picture to search for user on inside.spherion.com ////
    /// Still working on how to simply put 5-2 and pull image from inside.spherion.com at the myrow[image] call ////
    
    echo "
    <td>
    <a href=\"http://inside.spherion.com/Search.aspx?k={$myrow['LastName']}&s=Search%20People\" target=\"_blank\">
    <img src=\"" . $myrow['image']."\" /></a>
    <b><br>Last Name:</b>
    {$myrow['LastName']}
     
     </td>"; // echoing out the image   
     
     
    // Should we output a '</tr>'?
        if( $_pos === $_cols - 1 )
        {
            echo '</tr>';
        }
    }
    if( $_counter % $_cols !== $_cols - 1 )
    {
        do
        {
            echo '<td style="visibility: hidden">&nbsp;</td>';
        }
        while( ++$_counter % $_cols !== $_cols - 1 );
        
        echo '</tr>';
    }
     
    echo '
    </table>';
    } //end of loop
    
    
    } // End IF
     else {
    ("SELECT LastName FROM nocsis WHERE LastName NOT IN (Select LastName FROM image) AND TimeOut IS NULL ORDER BY TimeIn DESC");
    
    
     }
    
    
    
    ?>

    Comment

    Working...