Jump to content

justAnoob

Members
  • Posts

    561
  • Joined

  • Last visited

    Never

Everything posted by justAnoob

  1. Here is a update script that I use for some stuff. <?php //error_reporting(E_ALL); //ini_set('display_errors',1); session_start(); require 'connection.php'; if(isset($_POST['submit'])) { $item_name = mysql_real_escape_string($_POST['item_name']); $description = mysql_real_escape_string($_POST['description']); $in_return = mysql_real_escape_string($_POST['in_return']); $idnumber = mysql_real_escape_string($_POST['id']); $sql = "UPDATE table_name_here SET item_name = '$item_name', description = '$description', in_return = '$in_return' WHERE id = '$idnumber'"; if(mysql_query($sql)) { $_SESSION['updatecomplete'] = "Update Complete!"; header("location: http://www.--------.com/-------.php"); exit(); } else { $_SESSION['updateerror'] = "Error. Please try again later."; header("location: http://www.------.com/------.php"); exit(); } } ?>
  2. Sorry for the late post,, but I think I figured it out.
  3. This is easier on the eyes. <?php // Protect Variables from SQL injection function checkVars($value){ // Stripslashes if (get_magic_quotes_gpc()){ $value = stripslashes($value); } // Quote if not a number if (!is_numeric($value)){ $value = "'" . mysql_real_escape_string($value) . "'"; } return $value; }; // set Variables $clientID = checkVars($_GET['clientID']); mysql_select_db($database_admin , $admin); function photoCount($saleState, $clientID){ $SQL_countPhotos = "SELECT COUNT(photos.photoID), photos.saleState, photos.clientId FROM photos WHERE photos.saleState = '$saleState' AND photos.clientId = '$clientID'"; $rs_countPhotos= mysql_query($SQL_countPhotos, $admin); $row_countPhotos = mysql_fetch_assoc($rs_countPhotos); //echo $SQL_countPhotos; echo $row_countPhotos['COUNT(photos.photoID)']; } ?>
  4. I'm not too worried about having a line under the last one right now,, I just want to have a line in between each echoed row.
  5. I'm trying to echo a horizontal hr line inbetween each row that is echoed. Right now one line gets echoed underneath the last row. Where should I place the commented line below so that a line seperates each echoed row. <?php echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td align='center'>"; echo '<a href="viewitem.php?sendto='.$row['id'].'"><img src="' . $row['imgpath'] . '" width="125" border="0" alt=""></a>'; echo "</td><td align='center'>"; echo "".substr($row['item_name'],0,50),""; echo "</td><td align='center'>"; echo substr($row['description'],0,50).'<a href="viewitem.php?sendto='.$row['id'].'" class="view_item"> ...more</a>'; echo "</td><td align='center'>"; echo substr($row['in_return'],0,50).'<a href="viewitem.php?sendto='.$row['id'].'" class="view_item"> ...</a>'; echo "</td><td align='center'>"; echo "</td></tr>"; } echo "</table>"; echo '<hr width="550">'; /////////this line here ?>
  6. figured it out... <?php include "connection.php"; $sql="SELECT * FROM member_messages"; $result=mysql_query($sql); $count=mysql_num_rows($result); $checkbox = $_POST['checkbox']; if (count($checkbox) > 0) { for ($i=0;$i<count($checkbox);$i++) { $del_id = $checkbox[$i]; $sql = "DELETE FROM member_messages WHERE id = '$del_id' "; $result = mysql_query($sql); } if($result) { echo "Message(s) deleted."; } } mysql_close(); ?>
  7. I almost got it,, I think... Right now it deletes all the messages in the database(not good). I just want it to delete whatever checkboxes are selected. Look below, I'm not sure what to put in the WHERE clause. <form id="form2" name="form2" method="post" action="deletemessages.php"> <?php $stone = $_SESSION['id']; include "connection.php"; $sql = mysql_query("SELECT id, user_id, sendto, subject, message, datesent, status FROM member_messages WHERE sendto = '$stone'"); echo '<br><table width="950" border="0" align="center" cellpadding="0" cellspacing="0">'; while ($row = mysql_fetch_array($sql)) { echo '<tr><td width="39">'; echo '<input type="checkbox" name="checkbox[]" value="' . $row['id'] . '">'; echo '</td><td width="172">'; echo $row['user_id']; echo '</td><td width="453">'; echo '<a href="readandreply.php?messid=' . $row['id'] . '">' . $row['subject'] . '</a>'; echo '</td><td width="175">'; echo $row['datesent']; echo '</td><td width="115">'; echo '<font color="#006600">' . $row['status'] . ''; echo '</td></tr>'; } echo "</table><br><br>"; echo ' <input name="delete" type="submit" id="delete" value=" Delete " />'; ?> </form> <?php include "connection.php"; $sql="SELECT * FROM member_messages"; $result=mysql_query($sql); $count=mysql_num_rows($result); $checkbox = $_POST['checkbox']; if (count($checkbox) > 0) { for ($i=0;$i<count($checkbox);$i++) { $sql = "DELETE FROM member_messages WHERE id = ' WHAT TO PUT HERE ' "; // What should I put here? $result = mysql_query($sql); } if($result) { echo "Messages deleted."; } } mysql_close(); ?>
  8. what is wrong with this line <?php header("location: http://www.-----.com/viewitem.php?sendto=" . $idlookup . ""); ?>
  9. I don't want to be rude and I know others are busy helping others out, but is this something that is difficult to do? Or is this something small that I'm missing. I've been searching for a couple days on how to do this, and can't find anything anywhere.
  10. Still having problems... I echoed row id next to each checkbox to make sure that each checkbox had a value, and they did. I get the success message of the checkbox items being deleted,, but nothing really gets deleted. Any other ideas? <form id="form2" name="form2" method="post" action="deletemessages.php"> <?php $stone = $_SESSION['id']; include "connection.php"; $sql = mysql_query("SELECT id, user_id, sendto, subject, message, datesent, status FROM member_messages WHERE sendto = '$stone'"); echo '<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">'; while ($row = mysql_fetch_array($sql)) { echo '<tr><td width="39">'; echo '<input type="checkbox" name="checkbox[]" id="checkbox[]" value="' . $row['id'] . '">'; echo '</td><td width="172">'; echo $row['user_id']; echo '</td><td width="453">'; echo '<a href="readandreply.php?messid=' . $row['id'] . '">' . $row['subject'] . '</a>'; echo '</td><td width="175">'; echo $row['datesent']; echo '</td><td width="115">'; echo '<font color="#006600">' . $row['status'] . ''; echo '</td></tr>'; } echo "</table><br><br>"; echo '<input type="submit" name="submit" id="submit" value="Delete" />'; ?> </form> <?php include "connection.php"; $sql="SELECT * FROM member_messages"; $result=mysql_query($sql); $count=mysql_num_rows($result); for($i=0;$i<$count;$i++) { $del_id = $checkbox[$i]; $sql = "DELETE FROM member_messages WHERE id = '$del_id'"; $result = mysql_query($sql); } if($result) { echo "Messages deleted."; } mysql_close(); ?>
  11. Here is my form and the delete script... It echos that messages were deleted,,, but when I refresh the page and even check mysql database, everything is still there... Am I even close to getting this right? Form. <form id="form2" name="form2" method="post" action="deletemessages.php"> <?php $stone = $_SESSION['id']; include "connection.php"; $sql = mysql_query("SELECT id, user_id, sendto, subject, message, datesent, status FROM member_messages WHERE sendto = '$stone'"); echo '<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">'; while ($row = mysql_fetch_array($sql)) { echo '<tr><td width="39">'; echo '<input type="checkbox" name="checkbox[]" id="checkbox[]" value="' . $row['id'] . '">'; echo '</td><td width="172">'; echo $row['user_id']; echo '</td><td width="453">'; echo '<a href="readandreply.php?messid=' . $row['id'] . '">' . $row['subject'] . '</a>'; echo '</td><td width="175">'; echo $row['datesent']; echo '</td><td width="115">'; echo '<font color="#006600">' . $row['status'] . ''; echo '</td></tr>'; } echo "</table><br><br>"; echo '<input type="submit" name="submit" id="submit" value="Delete" />'; ?> </form> Delete script <?php include "connection.php"; $sql="SELECT * FROM member_messages"; $result=mysql_query($sql); $count=mysql_num_rows($result); for($i=0;$i<$count;$i++) { $del_id = $checkbox[$i]; $sql = "DELETE FROM member_messages WHERE id = '$del_id'"; $result = mysql_query($sql); } if($result) { echo "Messages deleted."; } mysql_close(); ?>
  12. How about when a user sends a new message,, have the mysql query set the status as new,, and then when a user clicks on a link to view the message, do a update to change the status?
  13. I'm working on a messaging system. What I'm looking to do is when I user recieves a message that is unread,, it marks it as new,, then after they have read the message, have it marked as nothing, cause it was read already. I have a column in my database called status. And users can already send messages. What is the next step so I can implement the status part?
  14. Tough crowd at 4 in the morning. No one has chimed in yet,,, any input?
  15. Here is the form with the script that shows the users pictures with the pagination integrated into it. <form id="form2" name="form2" method="post" action="updatepicture.php"> <?php session_start(); include "connection.php"; if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } $findit = $_SESSION['id']; $result = mysql_query("SELECT id FROM members WHERE username = '$findit' LIMIT 1"); $e_row = mysql_fetch_assoc($result); $query = mysql_query("SELECT count(*) FROM abcxyz WHERE user_id = " . $e_row['id']) or die(mysql_error()); $query_data = mysql_fetch_row($query); $numrows = $query_data[0]; $rows_per_page = 1; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) { $pageno = $lastpage; } if ($pageno < 1) { $pageno = 1; } $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; $sql = mysql_query("SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = " . $e_row['id'] . " $limit"); $_SESSION['rid_of_delete_button'] = $lastpage; if($lastpage != 0) { echo "<table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td width='188' height='180'><div align='center'>"; echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />'; echo "</div></td><td width='188'><div align='center'>"; if(empty($row['imgpath2'])) { echo '<div align="center"><a href="picture2.php"><img src="images/uploadanother.png" border="0"></a></div>'; } else { if(empty($row['imgpath2'])) { echo ""; } else { echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" /><a href="delete_image2.php"><font color="red"> X</a>'; } } echo "</div></td><td width='188'><div align='center'>"; if((empty($row['imgpath3'])) and (!empty($row['imgpath2']))) { echo '<div align="center"><a href="picture3.php"><img src="images/uploadanother.png" border="0"></a></div>'; } else { if(empty($row['imgpath3'])) { echo ""; } else { echo '<img src="' . $row['imgpath3'] . '" width="125" alt="" /><a href="delete_image3.php"><font color="red"> X</a>'; } } echo "</div></td><td width='188'><div align='center'>"; if( (empty($row['imgpath4'])) and (!empty($row['imgpath3'])) and (!empty($row['imgpath2'])) ) { echo '<div align="center"><a href="picture4.php"><img src="images/uploadanother.png" border="0"></a></div>'; } else { if(empty($row['imgpath4'])) { echo ""; } else { echo '<img src="' . $row['imgpath4'] . '" width="125" alt="" /><a href="delete_image4.php"><font color="red"> X</a>'; } } echo "</div></td><td width='190'><div align='center'>"; if( (empty($row['imgpath5'])) and (!empty($row['imgpath4'])) and (!empty($row['imgpath3'])) and (!empty($row['imgpath2'])) ) { echo '<div align="center"><a href="picture5.php"><img src="images/uploadanother.png" border="0"></a></div>'; } else { if(empty($row['imgpath5'])) { echo ""; } else { echo '<img src="' . $row['imgpath5'] . '" width="125" alt="" /><a href="delete_image5.php"><font color="red"> X</a>'; } } echo "</div></td></tr><tr><td height='43' colspan='4'>"; echo '<strong>Item Name:</strong> <input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" /> '; if ($pageno == 1) { echo " Previous Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'> Previous Item </a>"; } echo "($pageno of $lastpage)"; if ( $pageno == $lastpage ) { echo " Next Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'> Next Item </a>"; } echo "</td><td><div align='center'>"; echo '<input type="hidden" name="id" value="' . $row['id'] . '" size="25" />'; echo "</div></td></tr><tr><td height='116' colspan='4'>"; echo '<strong>Description:</strong> <textarea name="description" cols="75" rows="5">' . $row['description'] . '</textarea>'; echo "</td><td><div align='center'>"; echo '<input type="submit" name="submit" id="submit" value="Update Item">'; echo "</div></td></tr><tr><td height='124' colspan='4'>"; echo '<strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5">' . $row['in_return'] . ' </textarea>'; echo "</td><td><div align='center'>"; if(isset($_SESSION['updatecomplete'])) { unset($_SESSION['updateerror']); echo $_SESSION['updatecomplete']; } if(isset($_SESSION['updateerror'])) { unset($_SESSION['updatecomplete']); echo $_SESSION['updateerror']; } if(isset($_SESSION['picupload'])) { unset($_SESSION['updatecomplete']); unset($_SESSION['updateerror']); echo $_SESSION['picupload']; } echo "</div></td></tr><tr><td colspan='4'>"; echo '<input type="hidden" name="category" value="' . $row['category'] . '" size="25" />'; //echo "</td><td><div align='center'>"; //echo ''; echo "</td></tr>"; $_SESSION['move_id'] = $row['id']; $_SESSION['move_category'] = $row['category']; $_SESSION['path_1'] = $row['imgpath']; $_SESSION['path_2'] = $row['imgpath2']; $_SESSION['path_3'] = $row['imgpath3']; $_SESSION['path_4'] = $row['imgpath4']; $_SESSION['path_5'] = $row['imgpath5']; } echo "</table>"; } else { echo '<div align="center">You currently have no items.<br />Post your first item now!</div>'; } ?> </form> When a user deletes an image... this script does just that... <?php //error_reporting(E_ALL); //ini_set('display_errors',1); session_start(); require 'connection.php'; $id_gone = $_SESSION['move_id']; $image2 = $_SESSION['path_2']; $empty = ""; unlink($image2); $sql = "UPDATE abcxyz SET imgpath2 = '$empty' WHERE id = '$id_gone'"; if(mysql_query($sql)) { header("location: http://www.mypage.com/mypage.php"); // This should have a something refering to what page they were on. } ?>
  16. Alright,, I try this again,, I know its hard for someone when its not right in front of them... I have a page called.. http://www.mypage.com/mypage.php that is displayed with the users first picture. When they click the link to see there second picture.. the url shows. http://www.mypage.com/mypage.php?pageno=2... when the user clicks the link to go back to the first picture.. the url shows... http://www.tradekrazy.com/mytrades.php?pageno=1...... Each page gives the user the ability to update the picture and the name(which works great) but when they change something on page 2,, the browser will refresh and go back to http://www.mypage.com/mypage.php..... I would like it to go back to the page that they were on so they can instantly see the change that was made instead of going through the pages to find what they changed... I hope you understand this... Maybe you already did, and I'm not understanding what everyone was trying to tell me.
  17. Starting to get confused,,, though this would be easier.
  18. It says that my browser cannot display that web page.
  19. Again,,, All I want is to get the URL,, save it as a variable so I can use that in my header statement... The reason being is that lets say I have 10 pages with pictures.... And a user modifies a picture on page 6,, after the modification,, it takes the user back to to original page.... original page http://www.---------.com/-------.php page with whatever page there on http://www.--------.com/--------.php?pageno=2
  20. Something like that,,, but the progress bar on the bottom of my browser slowing gets to 100%,, really really slow.. and then does nothing.
  21. my page number is already setup through a pagination that I have through a script that displays the pictures... I'm just looking to get the URL and put it as a variable....
  22. I have a URL that changes depending on the page number,, like so... http://www.--------/-------.php?pageno=2 Is there a way to get the URL and put it in a variable so I can use that variable in a header statement header("location: http://www.---------.com/--------.php?$variable"); something like that
×
×
  • 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.