SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 52 of 52
  1. #51
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first page that collects the info for the main photos table (title, orientation, size etc) :

    PHP Code:
    <form action="validation.php" method="post" enctype="multipart/form-data" name="isc" id="form1">
    <
    table width="66%"  border="0" cellspacing="0" cellpadding="0">
    <
    tr>
    <
    td colspan="2" class="labelcell">File Name  * </td>
    <
    td class="fieldcell"><input name="uploadFile" type="file" size="55">
    <
    input type="hidden" name="MAX_FILE_SIZE" value="25000" /> </td>
    </
    tr>
    <
    tr>
    <
    td width="8%" class="labelcell">Title * </td>
    <
    td width="17%" class="labelcell">
    <
    div align="left">
    <
    input name="DefautButton" type="button" 
    onClick="Title.value=uploadFile.value?uploadFile.value:'No file'" value="File Name">
    </
    div></td>
    <
    td class="fieldcell">
    <
    input name="Title" type="text" id="Title" size="69">
    </
    td>
    </
    tr>
    <
    tr>
    <
    td colspan="2" class="labelcell">Link ID</td>
    <
    td width="75%" class="fieldcell"><input name="Link_ID" type="text" id="Link_ID" size="10"></td>
    </
    tr>
    <
    tr>
    <
    td colspan="2" class="labelcell">Supplier * </td>
    <
    td class="fieldcell">
    <
    input name="Supplier" type="text" id="Supplier" size="69">
    </
    td>
    </
    tr>
    <
    tr>
    <
    td colspan="2" class="labelcell">Rights * </td>
    <
    td class="fieldcell"><select name="Rights" id="Rights">
    <
    option value=" ">Select Rights</option>
    <
    option value="Unknown">Unknown</option>
    <
    option value="Licenced - Pay Licence per product">Licenced Pay Licence per product</option>
    <
    option value="Royalty Free - One off fee + credit">Royalty Free One off fee credit</option>
    <
    option value="Credited">Credited</option>
    </
    select></td>
    </
    tr>
    <
    tr>
    <
    td colspan="2" class="labelcell">Rights Details </td>
    <
    td class="fieldcell"><textarea name="Rights_Details" cols="52" rows="3" id="Rights_Details"></textarea></td>
    </
    tr>
    <
    tr>
    <
    td class="labelcell">Credit</td>
    <
    td class="labelcell">
    <
    div align="left">
    <
    input name="DefautButton" type="button" 
    onClick="Credit.value=Supplier.value" value="Supplier">
    </
    div></td>
    <
    td class="fieldcell">
    <
    input name="Credit" type="text" id="Credit" size="69">
    </
    td>
    </
    tr>
              
    etc

    <tr bgcolor="#FFFFFF">
    <
    td colspan="2">&nbsp;</td>
    <
    td><input name="Submit" type="submit" value="NEXT : Add photo keywords">
    <
    input type="reset" name="Reset" value="Reset form"></td>
    </
    tr>
    </
    table>
            
    </
    form
    This goes to a validation page, which inserts the data into the table :

    PHP Code:
    if (mysql_errno() == 0) {

     @
    mysql_select_db("photolibrary"$mysql_link);


    }

    if (
    mysql_errno() == 0) {

     
    $sqlcmd "INSERT INTO photos(Photo_File, Title, Link_ID, Supplier, Rights, Rights_Details, Credit, Orientation, Year, Country, Admin, Region, Easting, Northing, Tif, Width, Height) VALUES('$FTG_uploadFile', '$FTG_Title', '$FTG_Link_ID', '$FTG_Supplier', '$FTG_Rights', '$FTG_Rights_Details', '$FTG_Credit', '$FTG_Orientation', '$FTG_Year', '$FTG_Country', '$FTG_Admin', '$FTG_Region', '$FTG_Easting', '$FTG_Northing', '$FTGTif', '$FTGWidth', '$FTGHeight')";

     @
    mysql_query($sqlcmd$mysql_link);
     
    $Photo_ID mysql_insert_id (); 




    and then sends the user on to the Add Keywords page - which is still in it's original form with the hard coded checkboxes :

    PHP Code:
    <form name="form1" id="form1" method="POST" action="photoProfilesAdded.php">


    <
    table width="100%" border="0" cellspacing="0" cellpadding="0">

    <
    tr>
      <
    td colspan="10" valign="middle" class="labelcell"><span class="labelcell2">Places of Interest Buildings </span></td>
      </
    tr>

    <
    tr bgcolor="#FFFFFF">
    <
    input type='hidden' name='Photo_ID' value='<!--FIELDVALUE:Photo_ID-->'>
    <
    td class="keywordcell" width="2%" valign="middle"><input name="ckbox[2]" type="checkbox" class="tickbox2" id="ckbox[2]"></td>
    <
    td class="keywordcell2" width="18%">Ancient Monument </td>
    <
    td class="keywordcell" width="2%" valign="middle"><input name="ckbox[3]" type="checkbox" class="tickbox2" id="ckbox[3]"></td>
    <
    td class="keywordcell2" width="18%">Aquarium</td>

    etc 
    So again, just looking to do the same thing here as with the edit keywords code above - ie output them all using arrays.

  2. #52
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code in the edit keywords page looks like :

    PHP Code:
    Photo ID :<?php echo $Photo_ID?>


    <table width="942px" border="0" cellpadding="0" cellspacing="0" align="center">
        <form name="form1" method="POST" action="photoKeywordsEdited.php">
    <input type='hidden' name='Photo_ID' value='<?php echo $Photo_ID?>'>
    <?php require_once('Connections/Photolibrary.php');
    error_reporting(E_ALL E_STRICT);
    $Photo_ID 1
    if (isset(
    $_GET['Photo_ID'])) { 
      
    $Photo_ID intval($_GET['Photo_ID']); 

    mysql_select_db($database_Photolibrary$Photolibrary); 
    $query_Keyword_Match sprintf("SELECT * FROM photokeywords WHERE Photo_ID = %s"$Photo_ID); 
    $Keyword_Match mysql_query($query_Keyword_Match$Photolibrary) or die(mysql_error()); 
    $photokeywords = array(); 
    while (
    $row_Keyword_Match mysql_fetch_assoc($Keyword_Match)) { 
        
    $photokeywords[] = $row_Keyword_Match['Keyword_ID']; 

    $totalRows_Keyword_Match mysql_num_rows($Keyword_Match); 
    $sql "SELECT * FROM Keywords ORDER BY Keyword_ID";
    $keywordArray = array(); 
    $query mysql_query($sql); 



    while (
    $result=mysql_fetch_assoc($query)) { 
        
    $keywordArray[$result['Category']][] = $result

    $current_category ''

    foreach (
    $keywordArray as $categoryData


    if(
    $current_category <> $categoryData[2]['Category']) 
                { 
                    
    //open a new <tr> 
                    
    echo "<tr class=\"categorycell\">\n"
                    
    //print the category as a header 
                    
    echo "<td colspan=\"10\">"$categoryData[2]['Category']."</td>\n"
                    
    //close the <tr> 
                    
    echo "</tr>\n"
                    
    $current_category $categoryData[2]['Category'];

                }       

    $row_count 0;
    //even row 
    if($row_count%2==0

        
    $row_type 'even'

    //odd row 
    else 

        
    $row_type 'odd';             
    }

        echo(
    "<tr class=\"".$row_type."\">"); 
        foreach (
    $categoryData as $keywordData) { 
              

              
            echo(
    "<td><input "); 
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>');
            

             
            echo(
    "<td>".$keywordData['Keyword'].'</td>'); 
            

            
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        
        echo(
    '</tr>'); 
        
    $row_count++;




    ?>

    </table>
    <table>
    <tr>&nbsp;</tr>
      <tr>
      <td>
      <input type="submit" name="Submit" value="Update Photo Keywords">
      <input type=button value="Cancel" onClick="history.go(-1)">
      </form></td>

        </tr>
        
    </table>
    But I think needs to be a bit different in near the start setting up the array.

    Or at least doesn't need the

    PHP Code:
    mysql_select_db($database_Photolibrary$Photolibrary); 
    $query_Keyword_Match sprintf("SELECT * FROM photokeywords WHERE Photo_ID = %s"$Photo_ID); 
    $Keyword_Match mysql_query($query_Keyword_Match$Photolibrary) or die(mysql_error()); 
    ?


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
  •