Jump to content

Gazz1982

Members
  • Posts

    83
  • Joined

  • Last visited

Everything posted by Gazz1982

  1. Here is my code while($row = mysql_fetch_array($result2)) { echo "<form class='small' name='login' method='post' action='delete.php?<?php echo SID?>'>"; echo "<tr>"; echo "<td>"; echo "<input type='checkbox' name='delete' value='$del' /></td>"; echo "<td>" . $row['NAME_FIRST'] . "</td>"; echo "<td>" . $row['NAME_LAST'] . "</td>"; echo "<td>" . $row['EMAIL'] . "</td>"; echo "<td>" . $row['PASSWORD'] . "</td>"; echo "<td>" . $row['COMPANY'] . "</td>"; echo "<td>" . $row['ADDRESS1'] . "</td>"; echo "<td>" . $row['ADDRESS2'] . "</td>"; echo "<td>" . $row['ADDRESS3'] . "</td>"; echo "<td>" . $row['COUNTY'] . "</td>"; echo "<td>" . $row['COUNTRY'] . "</td>"; echo "<td>" . $row['POST_CODE'] . "</td>"; echo "<td>" . $row['PHONE'] . "</td>"; echo "<td>" . $row['VALIDATE'] . "</td>"; echo "<input type='checkbox' name='validate' value='$val' /></td>"; echo "<td>" . $row['ID'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "<input type='submit' name='Submit' value='delete' />"; echo "<input type='submit' name='Submit' value='validate' />"; echo "</form>"; A php generated table which loops through my database which lists everything from the database table. Also it has two sets of check boxes. 1. I want it so that when the delete checkbox is selected and the delete button is clicked it deletes this entry from the database. 2. There is a 2nd checkbox $val I want when this is checked and the validate button pressed, for the check box to stay checked and the entry in the validate colum to say 'yes' when unchecked to say 'no' default value 'no' All help is much appreciated Thank you in advance
  2. ok so now im getting delete name ID [] Bob 1 [] Dave 2 [] Time 3 when the table is created where ID is $del which = $row['ID'] The value in the check box is also $del [] = checkbox so now if I run select * from login where ID = $del it should select all of the ones which were checked ??? Am I right or close?
  3. ok looks like what i need echo "</table>"; echo"<br /><br />"; echo "<table border='1'> <tr> <th>Delete</th> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>Password</th> <th>Company</th> <th>Address1</th> <th>Address2</th> <th>Address3</th> <th>County</th> <th>Country</th> <th>Post Code</th> <th>Phone Number</th> <th>Validate</th> </tr>"; while($row = mysql_fetch_array($result2)) { echo "<tr>"; echo "<td><form class='small' name='login' method='post'>'"; echo "<input type='checkbox' name='Delete' value='<?php echo $rows['id']?>' /></p></td>"; echo "<td>" . $row['NAME_FIRST'] . "</td>"; echo "<td>" . $row['NAME_LAST'] . "</td>"; echo "<td>" . $row['EMAIL'] . "</td>"; echo "<td>" . $row['PASSWORD'] . "</td>"; echo "<td>" . $row['COMPANY'] . "</td>"; echo "<td>" . $row['ADDRESS1'] . "</td>"; echo "<td>" . $row['ADDRESS2'] . "</td>"; echo "<td>" . $row['ADDRESS3'] . "</td>"; echo "<td>" . $row['COUNTY'] . "</td>"; echo "<td>" . $row['COUNTRY'] . "</td>"; echo "<td>" . $row['POST_CODE'] . "</td>"; echo "<td>" . $row['PHONE'] . "</td>"; echo "<td>" . $row['VALIDATE'] . "</td>"; echo "</tr>"; } echo "</table>"; just trying to figure out this bit - sorry I'm a bit of a novice - all help welcomed $ids = join (',', $_POST['delID']); $sql = "DELETE FROM docs WHERE docID IN ($ids)"; mysql_query($sql);
  4. My php with mysql generates: Delete Name Address [] Checkbox Bob Down Town [] Checkbox Dave Down Town [] Checkbox Tim Down Town For the Checkbox: echo "<td><form class='small' name='login' method='post'"; echo "<input type='checkbox' name='Add' value='yes' /></td>"; I want to add 'yes' to my dispose column in my database, how do I update the database to the row which the checkbox is? ie If i check the box next to bob I want to add 'yes' to the dispose column only for Bob The checkboxes are generated through a loop so all will have the same name the mysql table as a unique id auto_increment primary key; Thanks for any help
  5. Thanks - I just figured it out myself - I'm rusty!
  6. hi I'm using: $result = mysql_query("SELECT * FROM login order by EMAIL") I want to select * except where column = admin how do I alter this? Thanks
  7. im using php - would i need to use javascript with it?
  8. my database: +------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+----------------+ | ID | int(11) | NO | PRI | NULL | auto_increment | | EMAIL | varchar(30) | NO | | NULL | | | PASSWORD | varchar(30) | NO | | NULL | | | NAME_FIRST | char(20) | YES | | NULL | | | NAME_LAST | char(20) | YES | | NULL | | | COMPANY | char(20) | YES | | NULL | | | ADDRESS1 | varchar(20) | YES | | NULL | | | ADDRESS2 | varchar(20) | YES | | NULL | | | ADDRESS3 | varchar(20) | YES | | NULL | | | COUNTY | char(20) | YES | | NULL | | | COUNTRY | char(20) | YES | | NULL | | | POST_CODE | varchar( | YES | | NULL | | | PHONE | varchar(30) | YES | | NULL | | | DISPOSE | char(3) | YES | | NULL | | +------------+-------------+------+-----+---------+----------------+ 14 rows in set (0.01 sec) this is displayed in a php generated table, I have added a checkbox to each row in the table - how do I make it so that when this check box is ticked it adds 'yes' into the dispose column of that row? Is this possible?
  9. OK NOW SET AS: while(!feof($fh)) { $line=fgets($fh); $temp = explode(",", $line); $description[$temp[0]] = $temp[1]; unset($temp); }
  10. I have this code which makes a 2 column table with images from a folder, it gets the captions from a text file - see below <?php $images = "uploads/"; # Location of small versions $big = "thumbs/"; # Location of big versions (assumed to be a subdir of above) $cols = 2; # Number of columns to display $text = "des.txt"; $fh=fopen($text, "r"); while(!feof($fh)) { $temp = explode(",", $line); $description[$temp[0]] = $temp[1]; $line=fgets($fh); unset($temp); } if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != rtrim($big,"/")) { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo '<table width="100%" cellspacing="3"><tr>'; foreach($files as $file) { if($colCtr %$cols == 0) echo '</tr><tr><td colspan="' . $cols . '"><hr /></td></tr><tr>'; $allfiles .= $file . ',<br />'; echo '<td align="center"><a href="' . $images . $big . $file . '"><img width="300px" src="' . $images . $file . '" /></a><br />' . $description[$file][0] . '</td>'; $colCtr++; } echo '</table>' . "\r\n"; echo $allfiles; ?> this file des.txt has file_name,caption however when implemented it only seems to display the 1st letter of the caption - any ideas why and how to solve? Thanks scan0006.jpg,Pic1 scan0005.jpg,scan0005.jpg scan0003.jpg, scan0009.jpg, scan0002.jpg, scan0008.jpg, scan0001.jpg, scan0004.jpg, scan0007.jpg,
  11. it displays the image from a folder but the $text part links a caption - currently it only displays the first letter for some reason
  12. any ideas why this happends? im stuck!
  13. I have this code: <? include("header.php") ?> <? include("side_left.php")?> <div class="middle"> <h1>Gallery</h1> <?php /* $images = "uploads/"; # Location of small versions $big = "images/"; # Location of big versions (assumed to be a subdir of above) $cols = 2; # Number of columns to display if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != rtrim($big,"/")) { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo '<table height="50px" cellspacing="3"><tr>'; foreach($files as $file) { if($colCtr %$cols == 0) echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>'; echo '<a href="' . $images . $big . $file . '"><img width="300px" src="' . $images . $file . '" /></a><br /><br />'; $colCtr++; } echo '</table>' . "\r\n"; ------------------- $images = "uploads/"; # Location of small versions $big = "thumbs/"; # Location of big versions (assumed to be a subdir of above) $cols = 2; # Number of columns to display if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != rtrim($big,"/")) { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo '<table width="100%" cellspacing="3"><tr>'; foreach($files as $file) { if($colCtr %$cols == 0) echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>'; echo '<td align="center"><a href="' . $images . $big . $file . '"><img width="200px" src="' . $images . $file . '" /></a></td>'; $colCtr++; } echo '</table>' . "\r\n"; */ $images = "uploads/"; # Location of small versions $big = "thumbs/"; # Location of big versions (assumed to be a subdir of above) $cols = 2; # Number of columns to display $text = "des.txt"; $fh=fopen($text, "r"); while(!feof($fh)) { $temp = explode(",", $line); $description[$temp[0]] = $temp[1]; $line=fgets($fh); unset($temp); } if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != rtrim($big,"/")) { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo '<table width="100%" cellspacing="3"><tr>'; foreach($files as $file) { if($colCtr %$cols == 0) echo '</tr><tr><td colspan="' . $cols . '"><hr /></td></tr><tr>'; $allfiles .= $file . ',<br />'; echo '<td align="center"><a href="' . $images . $big . $file . '"><img width="300px" src="' . $images . $file . '" /></a><br />' . $description[$file][0] . '</td>'; $colCtr++; } echo '</table>' . "\r\n"; echo $allfiles; ?> <br /> <br /> <br /> <br /> <br /> <br /> <br /> </div> <? include("side_right.php")?> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <? include("footer.php")?> it links to this text file for the descriptions des.txt file_name,text to display scan0006.jpg,Pic1 scan0005.jpg,Pic2 scan0003.jpg,Pic3 scan0009.jpg,Pic4 scan0002.jpg, scan0008.jpg, scan0001.jpg, scan0004.jpg, scan0007.jpg, This only displays the 1st letter how do I fix it?
  14. I'm nearly there! $uploaddir1 = 'uploads/'; $uploaddir2 = "uploads/thumbs/"; $uploadfile1 = $uploaddir1 . $_FILES['upfile']['name']; $uploadfile2 = $uploaddir2 . $_FILES['upfile']['name']; if (!file_exists('$uploaddir1 . $uploadfile1')) { copy($_FILES['upfile']['tmp_name'],$uploadfile1); copy($_FILES['upfile']['tmp_name'],$uploadfile2); }else{ echo "file already exists";}; ?> the file_exists should be checking the upload_directory/file_name if it doesn't exist then copy else don't copy - this doesn't seem to be working quite right - any obvious errors?
  15. gave this error File upload success Warning: copy(uploads/Array) [function.copy]: failed to open stream: No such file or directory in /var/www/uploader.php on line 20 failed to copy uploads/Array... <?php $uploaddir1 = "uploads/"; $uploaddir2 = "uploads/thumbs/"; $uploadfile1 = $uploaddir1 . $_FILES['upfile']['name']; if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile1)) { print("File upload success"); } else { print("Failed"); } $file = $uploaddir1 . $_FILES['upfile']; $newfile = $uploaddir2 . $_FILES['upfile']; if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } am I close?
  16. I have 2 scripts how do I combine them as they wont work like this? I want an image to be uploaded to the uploads/ directory and the uploads/thumbs/ directory <?php $uploaddir1 = "uploads/"; $uploadfile1 = $uploaddir1 . $_FILES['upfile']['name']; if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile1)) { print("File upload success"); } else { print("Failed"); } $uploaddir2 = "uploads/thumbs/"; $uploadfile2 = $uploaddir2 . $_FILES['upfile']['name']; if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile2)) { print("<br />Thumbnail upload success"); } else { print("<br />Thumbnail Failed"); } ?>
  17. I'm trying to upload an image from 1 file to to locations how can I combine these 2 scripts together <?php $uploaddir1 = "uploads/"; $uploadfile1 = $uploaddir1 . $_FILES['upfile']['name']; if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile1)) { print("File upload success"); } else { print("Failed"); } ?> <?php $uploaddir2 = "uploads/thumbs/"; $uploadfile2 = $uploaddir2 . $_FILES['upfile']['name']; if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile2)) { print("<br />Thumbnail upload success"); } else { print("<br />Thumbnail Failed"); } ?>
  18. Im using this code to upload an image from a form <?php $uploaddir = "uploads/"; $uploadfile = $uploaddir . $_FILES['upfile']['name']; if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile)) { print("File upload success"); } else { print("Failed"); } ?> I want add so that the file is also sent to another file This file needs to be a thumb nail so 100px wide is this possible?
  19. I'm trying to upload images to a directory on my server using: <form enctype="multipart/form-data" action="uploader.php" method="POST"> Please choose a file: <input name="upfile" type="file" /><br /> <input type="submit" value="Upload" /> </form> <?php $uploaddir = "uploads/"; $uploadfile = $uploaddir . $_FILES['upfile']['name']; if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile)) { print("File upload success"); } else { print("Failed"); } ?> Warning: move_uploaded_file(uploads/image001.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /var/www/uploader.php on line 5 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpq2fKYW' to 'uploads/image001.jpg' in /var/www/uploader.php on line 5 Failed I've set dir uploads/ permissions using chmod 766 uploads Any ideas?
  20. or is their a check box option for a mysql database? I have set it as DISPOSE CHAR(3)
  21. sorry I have generated a table using php from a query I've made another column generate a checkbox (not linked to database) I want it so that when this is checked it updates the dispose column with the value: 'yes' is that clearer?
  22. I have a check box, when it is ticked I want it to ("insert 'yes' into dispose where (the checkbox is in the same table <td> </td> bit)") this code needs to be executed in another php file - so it is clicked then a button is pressed which goes (location:file.php) and then that row is deleted using ("delete * from login where ($_POST('varible'))"); here is my code so far <?php $con = mysql_connect("localhost","root","Gnob2007"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("register", $con); $result = mysql_query("SELECT * FROM login where VALIDATE = 'yes'"); echo "<table border='1'> <tr> <th>Delete</th> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>Password</th> <th>Company</th> <th>Address1</th> <th>Address2</th> <th>Address3</th> <th>County</th> <th>Country</th> <th>Post Code</th> <th>Phone Number</th> <th>Validate</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td><form class='small' name='login' method='post' action='delete.php?<?php echo SID?>'"; echo "<input type='checkbox' name='Delete' value='Delete' /></p></td>"; echo "<td>" . $row['NAME_FIRST'] . "</td>"; echo "<td>" . $row['NAME_LAST'] . "</td>"; echo "<td>" . $row['EMAIL'] . "</td>"; echo "<td>" . $row['PASSWORD'] . "</td>"; echo "<td>" . $row['COMPANY'] . "</td>"; echo "<td>" . $row['ADDRESS1'] . "</td>"; echo "<td>" . $row['ADDRESS2'] . "</td>"; echo "<td>" . $row['ADDRESS3'] . "</td>"; echo "<td>" . $row['COUNTY'] . "</td>"; echo "<td>" . $row['COUNTRY'] . "</td>"; echo "<td>" . $row['POST_CODE'] . "</td>"; echo "<td>" . $row['PHONE'] . "</td>"; echo "<td>" . $row['VALIDATE'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> thanks for any help
  23. This displays my table: echo "<table border='1'> <tr> <th>Delete</th> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>Password</th> <th>Company</th> <th>Address1</th> <th>Address2</th> <th>Address3</th> <th>County</th> <th>Country</th> <th>Post Code</th> <th>Phone Number</th> <th>Validate</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td><form class='small'>'"; echo "<input type='checkbox' name='Delete' value='Delete' /></p></td>"; echo "<td>" . $row['NAME_FIRST'] . "</td>"; echo "<td>" . $row['NAME_LAST'] . "</td>"; echo "<td>" . $row['EMAIL'] . "</td>"; echo "<td>" . $row['PASSWORD'] . "</td>"; echo "<td>" . $row['COMPANY'] . "</td>"; echo "<td>" . $row['ADDRESS1'] . "</td>"; echo "<td>" . $row['ADDRESS2'] . "</td>"; echo "<td>" . $row['ADDRESS3'] . "</td>"; echo "<td>" . $row['COUNTY'] . "</td>"; echo "<td>" . $row['COUNTRY'] . "</td>"; echo "<td>" . $row['POST_CODE'] . "</td>"; echo "<td>" . $row['PHONE'] . "</td>"; echo "<td>" . $row['VALIDATE'] . "</td>"; echo "</tr>"; echo "<input type='submit' name='Delete' value='Delete' target='delete.php?'/></p>"; } echo "</table>"; I have a check box titled delete once this is checked I want to pass everything from that row to delete.php where the whole row is delete. I have a column in the database called delete so I assume that I need to insert into login where (checkbox is ticked == true) using some kind of if statement - if checkbox ticked == true insert 'yes' into delete then delete * from login where delete ='yes' How do I do this? see www.noblesweb.co.uk/manager.php Thanks
×
×
  • 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.