SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    england
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    joins not working!

    can some oen please give me a hand here!

    PHP Code:
    <?php

    include ("db.php");
    $id $_POST ['id'];
    $type $_POST['type'];
    $brand $_POST['brand'];
    $title $_POST['title'];
    $file1 $_POST['img'];
    $fileName1 $_FILES['img']['name'];
    $file2 $_POST['img_big'];
    $fileName2 $_FILES['img_big']['name'];
    $page $_GET['page'];
    $limit "12";
    $limitvalue $page $limit - ($limit);


    $query "SELECT * FROM `dickinsons_products, dickinsons_logo`  LIMIT $limitvalue$limit";
    $result mysql_query($query)
        or die (
    "couldnt add to db".mysql_error());
        
        
    //this is for the paination page 
    $query_count "SELECT * FROM 'dickinsons_products, dickinsons_logo'";
    $result_count mysql_query($query_count)
    or die (
    "count not do result_count".mysql_error());

    $nrows mysql_num_rows($result_count);   



    //says to make teh results accross by however many needed, then fecth results not two hidden fields one to delete and one for id
    define('ITEMS_PER_ROW'3); 

    $cells = array(); 
    while(
    $rec mysql_fetch_assoc($result)) 
        
    $cells[] = 
            
    "<td>" 
                
    "<div align=\"center\"><form name=\"deletephoto\" method=\"post\" action=\"http://www.hunterjohnstone-gallery.co.uk/dickinsons/admin/delRecord.php\">
                <input name=\"delete\" type=\"image\" value=\"delete\" src=\"http://www.hunterjohnstone-gallery.co.uk/dickinsons/images/delete.gif\"  align=\"center\">
                <input name=\"id\" type=\"hidden\" id=\"id\" value=\"" 
    $rec['id'] . "\">
                <input name=\"img\" type=\"hidden\" id=\"img\" value=\"" 
    $rec['img'] . "\">
               </form>
                
          <a href=\"http://www.hunterjohnstone-gallery.co.uk/dickinsons/images/photo/" 
    $rec['img_big'] . "\" target=\"blank_\">" "<img src=\"http://www.hunterjohnstone-gallery.co.uk/dickinsons/images/photo/" $rec['img'] ."\"  border=\"0\"></a></div>" .
            
    "<div align=\"center\" class=\"text\">" $rec['img'] . "</div>" .
            
    "<div align=\"center\" class=\"bold\">" $rec['type'] . "</div>" .
           
    "<div align=\"center\" class=\"text\">" $rec['brand'] . "</div>" .
          
    "<div align=\"center\" class=\"text\">" $rec['title'] ."</div><p></p>" .   
          
    "</td>"
            
            
            
    if(
    $c count($cells) % ITEMS_PER_ROW
        
    $cells array_pad
            
    $cells
            
    count($cells) + (ITEMS_PER_ROW $c), 
            
    "<td>&nbsp;</td>" 
        
    ); 

    echo 
    "<table border=0 align=center width=100%>"
    foreach(
    array_chunk($cellsITEMS_PER_ROW) as $row
        echo 
    "<tr>" implode("\n"$row) . "</tr><tr><td colspan=4><hr width=90% color=#0B8CA9></td></tr>"
    echo 
    "</table>"
        
    echo 
    "<div align=center>";    
    include (
    "paginationDelete.php");
    echo 
    "</div>";
    ?>
    im getting an eorror saying "'dickinsons_products, dickinsons_logo' doesn't exist" im guessing cos i have the wrong JOIN code. ive tried everything tho!
    ps its falling over on the first one!

    thanks

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have two problems here 1 PHP related the other SQL related.

    1) PHP related you have not connected to your database. Look up how to do that in the PHP manual

    2) YOu have not joined your tables correctly so you will get a cross join, returning a result of all rows in table a multiplied by all rows of table b as a total number of rows. You either need a WHERE tablea.column1 = tableb.column2 in your join or write it with an ON tablea.column1 = tableb.column2 condition. Search this site for examples of how to do a join if you need further clarification.

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    also you cannot put the table names in single quotes, that turns them into strings

    backticks are okay (but only necessary if the table name would be a reserved word or contains special characters like a space)

    so it should be

    SELECT * FROM dickinsons_products, dickinsons_logo

    or

    SELECT * FROM `dickinsons_products`, `dickinsons_logo`

    but not

    SELECT * FROM `dickinsons_products, dickinsons_logo`
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •