Deleting and editing is accomplished by selecting out of the db the
appropriate record. So if you had a page that looped through 35 (for
example) records, and each record had a link that was created (<a
class='link_black_02' href='deletephotoconfirm.php?photoid=$photoid'>" .
"delete" . "</a>) -- use the querystring to pass the $photoid to a
confirmation page. On that confirmation page (I usually do this) create 2
forms with one button in each. Both post/get to the processing page, one
button has a value (for example) 'dodelete' and the other form's button
'dontdoit'. Then at the top of the processing page, figure out which button
was pressed and go from there.  For editing the actual path for the image,
it is done the same old way, select the record according to an id, dump the
values you want changed into a form , edit and post/get it back up the same
way it was done the first time around.

Hope this helps you out :)

Joe/ Lerp :)

######################grab records from
db################################################################

$connectionToDB = odbc_connect("gdff", "jgdfoldff", "jdfdfgrf");
$sqlp = "SELECT photoid, caption, datesubmitted FROM PHOTO WHERE
golferid='$sesgolferid'" . " ORDER BY datesubmitted DESC";
$resultset = odbc_do($connectionToDB, $sqlp);

//start table for display here
print "<table width='500' cellspacing='0' cellpadding='0' border='0'>";

  print "<tr colspan='3'>";
  print "<td bgcolor='#363C70' colspan='3'><img
src='images/pixel_transparent.gif' width='1' height='5' border='0'
alt=''></td>";
  print "</tr>";

  print "<tr>";
  print "<td bgcolor='#363C70' align='left' width='200'>";
  print "<font face='verdana' color='#FFFFFF' size='2'
class='text_size_9'>";
  print "<b>Caption</b>";
  print "</font>";
  print "</td>";
  print "<td bgcolor='#363C70' align='left' width='230'>";
  print "<font face='verdana' color='#FFFFFF' size='2'
class='text_size_9'>";
  print "<b>Date Submitted</b>";
  print "</font>";
  print "</td>";
  print "<td bgcolor='#363C70' align='left' width='70'>";
  print "<font face='verdana' color='#FFFFFF' size='2'
class='text_size_9'>";
  print "<b>Delete</b>";
  print "</font>";
  print "</td>";
  print "</tr>";

  print "<tr>";
  print "<td bgcolor='#363C70' colspan='3'><img
src='images/pixel_transparent.gif' width='1' height='5' border='0'
alt=''></td>";
  print "</tr>";

print "<tr height='10'></td></td></tr>";


while(odbc_fetch_row($resultset)){

$photoid = odbc_result($resultset,1);
$caption = odbc_result($resultset,2);
$datesubmitted = odbc_result($resultset,3);


//format the datesubmitted for display below
$month = substr($datesubmitted, 5, 2);
//print $month . "<BR>";
$day = substr($datesubmitted, 8, 2);
//print $day . "<BR>";
$year = substr($datesubmitted, 0, 4);
//print $year . "<BR>";

$dateinsecs = mktime(0,0,0,$month, $day, $year);


$formattedsubdate = date('F j Y',$dateinsecs);
//print $formattedsubdate;


file://display the records --create a link for
each###############################
print "<tr>";
print "<td align='left' bgcolor='#ffffff' width='200'><b><font
face='verdana' color='#000000' size='2' class='text_size_9'>"  .  $caption .
"</font></b></td>" .  "<td align='left' width='230' bgcolor='#ffffff'><font
face='verdana' color='#000000' size='2' class='text_size_9'>" .
$formattedsubdate . "</font></td>" .  "<td align='left' width='70'
bgcolor='#ffffff'><font face='verdana' color='#000000' size='2'><b><a
class='link_black_02' href='deletephotoconfirm.php?photoid=$photoid'>" .
"delete" . "</a></b></font></td>";
print "</tr>";
print "<tr height='10'></td></td></tr>";
}

}



// close the connection
odbc_close($connectionToDB);

##############end of display from
database#######################################################




##############confirmation
page##############################################################


<div align='center'>
<table cellspacing="0" cellpadding="5" border="0" >
  <tr>
      <td align="center">

    <form action="dodeletep.php" method="post">
    <input type="hidden" name="photoid" value="<?php echo $photoid; ?>">

    <input type="hidden" name="dodelete" value="dodelete">
    <input type="Submit" name="submit" value="&nbsp;&nbsp;Yes&nbsp;&nbsp;"
style="background-color: #FFFFFF; font-family: verdana; font-weight: bold;
color: #363C70; font-size: 10pt;">
    </form>

   </td>
   <td align="center">

    <form action="dodeletep.php" method="post">
    <input type="hidden" name="photoid" value="<?php echo $photoid; ?>">

    <input type="hidden" name="dontdelete" value="dontdelete">
    <input type="Submit" name="submit"
value="&nbsp;&nbsp;No&nbsp;&nbsp;&nbsp;" style="background-color: #FFFFFF;
font-family: verdana; font-weight: bold; color: #363C70; font-size: 10pt;">
    </form>

   </td>
  </tr>
  </table>

</div>

 ################end of confirmation
page###################################################


###############processing
page###########################################################

<?php session_start(); ?>
<?php

if (!isset($HTTP_SESSION_VARS["islogged"])){

header("Location:index.php");
}

if(isset($dodelete)){

//connect to db
$connectionToDB = odbc_connect("gfghf", "jofgh6lf", "hghdfg");

//determine which file to delete off of the server (and delete it) before
deleting it out of db

$sqlphoto = "SELECT photo FROM PHOTO WHERE photoid='$photoid'";
$deletephotoid = odbc_do($connectionToDB, $sqlphoto);
$pi = odbc_result($deletephotoid, 1);

//print "Photo name is; " . $pi . "<BR>";
$pi = trim($pi);
$pi = substr($pi,5);

//print "File to be deleted is: " . $pi . "<br>";

//actual deletion of file off of server
unlink("pics/" . $pi);

$sqldel =  "DELETE FROM PHOTO WHERE photoid ='$photoid'";

odbc_do($connectionToDB, $sqldel);
}
else
{
header("Location:photos.php");
}


// close the connection
odbc_close($connectionToDB);
?>



###############end of processing
page###########################################################










"Will Hives" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> That's cool.
>
> How do you then delete and edit that image?
>
> Will
>
>
>
>
>
>
>
>
>
> in article [EMAIL PROTECTED], Lerp at
> [EMAIL PROTECTED] wrote on 2/1/2002 5:07 PM:
>
> > Hi there, here's a bit of code to get you started. It includes a form
that
> > allows uploads, and the code to process the upload on the receiving
page.
> > Basically, you have a form that allows an upload of a file on one page,
and
> > some code on the receiving page to insert a path to that file in the
> > database and store the newly uploaded file in a directory on the
webserver.
> > Of course you'll have to ensure that you have the proper write and read
> > permissions on that folder. There are a few 'print' lines sprinkled
> > throughout the code. For debugging you might want to un-comment them to
see
> > how everything is working.
> >
> > Hoe this helps you out!
> > Joe/Lerp :)
> >
> >
> > Here's a common form that allows you to upload a file (say an image or
any
> > type of file for that matter) to the
> > db
> >
> > <form action='upload.php' method='post' enctype='multipart/form-data'>
> > <input type='hidden' name='MAX_FILE_SIZE' value='25000'>
> > <P><font color='#ffffff' face='verdana' size=1>Upload
Photo:</font><input
> > type='file' name='userfile'><input type='submit'
> > value='Upload!!!'></form></p>
> >
> > ################################end of upload form
> > ##############################################################
> >
> >
> > ############################start of upload process to db
> > ################################################################
> > <?php
> >
> >
> > #$userfile is the file being uploaded
> >
> >
> >
> >
> > file://print $userfile . "<BR>";
> > file://print $userfile_name . "<BR>";
> >
> > file://determine file size -- if too big ( greater 50kb) then redirect
> > $siz = filesize($userfile);
> > file://print $siz;
> >
> > $ext = substr($userfile_name, -4);
> >
> >
> > // if the file not of type 'jpg' then redraw out upload form
> > if($ext != ".jpg"){
> > print "<font face='verdana' size='2' class='text_size_9'>The photo you
> > attempted to upload was of the wrong file type. Please ensure that the
file
> > type is a 'jpg'.</font>";
> > print "<form method='POST' action='photoupload2.php'
> > enctype='multipart/form-data'><input type='file' name='userfile'
size='15'
> > style='font-family: Verdana; font-size: 8pt;'><input type='submit'
name='sub
> > mit' value='Upload' style='font-family: Verdana; font-size: 8pt;'>";
> > print "</form>";
> > print "</td></tr></table>";
> > print "<table width='470' cellspacing='10' cellpadding='10'
border='0'>";
> > print "<tr><td height=30></td><td height=30></td></tr>";
> > print "<tr><td align=left><form name='forma' method=''
> > action='photos.php'><input type='submit' name='submit'
> > value='&laquo;&nbsp;Photos' style='background-color: #FFFFFF;
font-family:
> > verdana; font-weight: bold; color: #363C70; font-size:
> > 10pt;'></form></td><td></td></tr>";
> > print "</table></td>";
> > print "<td width='1' bgcolor='#FFFFFF' height='341'><img
> > src='images/pixel_transparent.gif' width='1' height='1' border='0'
> > alt=''></td>";
> > print "<td width='245' bgcolor='#363C70' align='center' valign='top'
> > height='341'>";
> > print "<table cellspacing='0' cellpadding='0' border='0'>";
> > print "<tr> <td></td></tr><tr>";
> > print "<td bgcolor='#FFFFFF'><img src='images/pixel_transparent.gif'
> > width='1' height='1' border='0' alt=''></td></tr></table>";
> > print "<table cellspacing='0' cellpadding='5' border='0'><tr>";
> > print "<td><img src='images/bullet_quick_tips_small.gif' width='17'
> > height='17' border='0' alt=''></td>";
> > print "<td><font face='verdana' size='1' class='text_size_8'> <a
> > href='contact.php' class='link_white_02'>Send us some
> > feedback!</a></font></td>";
> > print "</tr></table></td></tr></table>";
> >
> > exit;
> > }
> >
> > if ($siz >= 51200){
> >
> > file://redraw upload form
> > print "<font face='verdana' size='2' class='text_size_9'>The photo you
> > attempted to upload was too large in file size. Please ensure that the
file
> > size does not exceed 50kb.</font>";
> > print "<form method='POST' action='photoupload2.php'
> > enctype='multipart/form-data'><input type='file' name='userfile'
size='15'
> > style='font-family: Verdana; font-size: 8pt;'><input type='submit'
> > name='submit' value='Upload' style='font-family: Verdana; font-size:
> > 8pt;'>";
> > print "</form>";
> >
> > }
> > elseif ($siz < 51200)
> > {
> >
> > $timestamp = time();
> > $userfile_name = $timestamp.$userfile_name ;
> >
> > // copy the file being posted -- remember to escape backslashes!!!
> > if(copy($userfile, "/ez/golfPHP/pics/". $userfile_name)){
> > print "<font face='verdana' size='2' class='text_size_9'>Your photo has
> > been uploaded and is viewable in the photo gallery.</font><br><br>" ;
> > }
> > else
> > {
> > print "<font face='verdana' size='2' class='text_size_9'>A problem was
> > encountered during your photo upload.</font><br>";
> > }
> >
> > $patharola = "pics/". $userfile_name;
> > file://print $patharola;
> >
> > $caption = "No Caption.";
> >
> > // insert path into database here
> > file://connect to db
> > $connectionToDBid = odbc_connect("golf", "joegolf", "joegolf");
> >
> > file://create query statement
> > $sqlr = "INSERT INTO PHOTO (golferid, photo, caption, datesubmitted)
VALUES
> > ('$sesgolferid' , '$patharola', '$caption', '$todaysdate' )";
> > file://execute the sql statement (query) on the connection made
> > $resultset = odbc_do($connectionToDBid, $sqlr);
> >
> > file://grab the photoid from db
> > $sqlid = "SELECT @@IDENTITY AS NewId";
> > $napid = odbc_do($connectionToDBid, $sqlid);
> > $photoid = odbc_result($napid, 1);
> >
> > file://print "Photo Id is: " . $photoid . "<BR>";
> >
> > // close the connection
> > odbc_close($connectionToDBid);
> >
> >
> >
> > ?>
> >
> > ################################end of insert to db process
> > ##################################################
> >
> >
> >
> >
> >
> >
> >
> >
> > "Artisthotel" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >> Hi,
> >>
> >> I need an upload script that lets predefined users log in and upload
> > files.
> >> Does such a script exist?
> >>
> >> Regards
> >> JEns
> >>
> >>
> >
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to