justAnoob Posted June 3, 2009 Share Posted June 3, 2009 Below I have a page that displays some records from mysql through a pagination setup only allowing 1 row per page. That works great. What I am also trying to do is add a drop down box with a list of records for each user so the user can pick a row out instead of hitting the next button 50 times to get to there 50th picture. I have a drop down box on the page(which i put in a separate code bracket below) The question is how would I go about having it so when the user clicks on one of the rows in the drop down box, it then shows that picture? <?php <form id="form2" name="form2" method="post" action="updatetrade.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 </a>"; } echo "($pageno of $lastpage)"; if ( $pageno == $lastpage ) { echo " Next Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'> Next </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']; $_SESSION['last_page'] = $_SERVER['PHP_SELF']; } echo "</table>"; } else { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; } ?> </form> ?> <?php $droppy="SELECT id, item_name FROM abcxyz WHERE user_id = " . $e_row['id'] . ""; $catch = mysql_query($droppy); echo "<select name=student value=''>xxxxx</option>"; while($xxx=mysql_fetch_array($catch)) { echo "<option value=$xxx[id]>$xxx[item_name]</option>"; } echo "</select>"; ?> And yes,, I use a lot of sessions. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted June 3, 2009 Share Posted June 3, 2009 <?php session_start(); include "connection.php"; echo '<form id="form2" name="form2" method="post" action="updatetrade.php">'; /*Lol loving the nested PHP tags but that wont work =( and you cant output anything to the screen before session_start(); */ 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 </a>"; } echo "($pageno of $lastpage)"; if ( $pageno == $lastpage ) { echo " Next Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'> Next </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']; $_SESSION['last_page'] = $_SERVER['PHP_SELF']; } echo "</table>"; } else { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; } ?> </form> Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 3, 2009 Author Share Posted June 3, 2009 don't mind the extra tags in there,, sorry about that,, they got put in there by accident when i posted this topic. not really in the script. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted June 3, 2009 Share Posted June 3, 2009 <?php session_start(); //etc. if ( isSet($_POST['selec']) ) { if ( !empty($_POST['options']) ) { $first = true; forEach($options as $queVal) { if ( isSet($first) ) { $buildQue = ' AND id = ' . intVal($queVal) . ' '; $first = false; }else{ $buildQue .= 'OR id = ' . intVal($queVal) . ' '; } } } } //etc... $sql = mysql_query("SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = " . $e_row['id'] . " " . $buildQue . " $limit"); <form method="post" action=""> <select name="options[]" multiple="multiple"> <?php $droppy = "SELECT id, item_name FROM abcxyz WHERE user_id = " . $e_row['id'] . ""; $xxx = mysql_query($droppy)or trigger_error(mysql_error()); while ( $row = mysql_fetch_row($xxx) ) { echo ' <option value=' . $row[0] . '>' . $row[1] . '</option>'; } ?> </select><input type="submit" name="selec" value="Show Selected" > </form> Try that.. Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 3, 2009 Author Share Posted June 3, 2009 Sorry for the misunderstanding.. my drop down box is inside a form already(which already has an action) And I can't put the drop down box outside the form because that is where all my data is displayed. I'm getting tired... Here is the whole script with a commented spot where I would like to put the drop down box at.. Again, sorry for the confusion. If you any spare time, could you please take anothe look. Oh yeh,, I would still like to keep the pagination in case the user just wants to browse his/her pics. Just want the drop down box there so they can go straight to a picture. Thanks. <?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 </a>"; } echo "($pageno of $lastpage)"; if ( $pageno == $lastpage ) { echo " Next Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'> Next </a>"; } ///////////////////////////////////////////// Drop down box here ////////////////////////////// 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']; $_SESSION['last_page'] = $_SERVER['PHP_SELF']; } echo "</table>"; } else { echo '<div align="center">You currently have no pictures.<br />Post your first item now!</div>'; } ?> </form> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 3, 2009 Share Posted June 3, 2009 Ugh... that code is a nightmare. Cleaned it up and added the drop-down. This should work. <?php session_start(); include "connection.php"; echo '<form id="form2" name="form2" method="get" action="updatetrade.php">'; /*Lol loving the nested PHP tags but that wont work =( and you cant output anything to the screen before session_start(); */ $pageno = isset($_GET['pageno'])? intval($_GET['pageno']) : 1; $findit = intval($_SESSION['id']); $result = mysql_query('SELECT m.id, COUNT(*) AS count FROM abcxyz a INNER JOIN members m ON m.id = a.user_id WHERE m.username="' . $findit .'" LIMIT 1') or trigger_error('User not found.', E_USER_ERROR); $member_info = mysql_fetch_row($result); $member_id = $member_info[0]; $numrows = $member_info[1]; $rows_per_page = 1; $_SESSION['rid_of_delete_button'] = $lastpage = ceil($numrows/$rows_per_page); $_SESSION['last_page'] = $_SERVER['PHP_SELF']; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) $pageno = $lastpage; else if ($pageno < 1) $pageno = 1; $limit = 'LIMIT '. (($pageno - 1) * $rows_per_page) . ',' . $rows_per_page; $sql = <<<QUERY SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = $member_id $limit QUERY; $result = mysql_query($sql) or trigger_error('Select SQL failed.', E_USER_ERROR); if ($lastpage === 0) { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; exit; } ?> <table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'> <?php // $dropdown[img_id] = img_name $dropdown = array(); // for performance sake, just run another query even though $sql already selects the data we want. // this will be faster than for PHP to do. $dropdown_sql = 'SELECT id, item_name FROM abcxyz WHERE user_id = ' . $member_id; $dropdown_result = mysql_query($dropdown_sql) or trigger_error('Select SQL failed.', E_USER_ERROR); $dropdown_menu = '<select name="pageno">'; while ($row = mysql_fetch_assoc($dropdown_result)) { $dropdown_menu .= '<option value="' . $row['id'] . '">' . $row['item_name'] . '</option>'; } while ($row = mysql_fetch_assoc($sql)) { $dropdown[$row['id']] = $row['item_name']; echo '<tr>'; for ($e = 2; $e < 6; $e++) { echo '<td width="188" height="180"><div align="center"><img src="' . $row['imgpath'] . '" width="125" alt="image 1" /></div></td><td width="188"><div align="center">'; echo empty($row['imgpath' . $e])? '<a href="picure2.php"><img src="images/uploadanother.png" border="0"></a>' : '<img src="' . $row['imgpath' . $e] . '" width="125" alt="" /><a href="delete_image' . $e . '.php"><span style="color: red;"> X</span></a>'; echo '</div></td>'; } echo '</tr><tr><td height="43" colspan="4"><strong>Item Name:</strong><input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" />  '; echo $pageno == 1? ' Previous Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $prevpage . '"> Previous </a>(' . $pageno . ' of ' . $lastpage . ')'; echo $pageno == $lastpage? ' Next Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $nextpage . '"> Next </a>'; ?> </td> <td><div align="center"><input type="hidden" name="id" value="<?php echo $row['id']; ?>" size="25" /></div></td> </tr> <tr> <td height="116" colspan="4"><strong>Description:</strong> <textarea name="description" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center"><input type="submit" name="submit" id="submit" value="Update Item"></div></td> </tr> <tr> <td height="124" colspan="4"><strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center">'; <?php 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']; } ?> </div><td> </tr> <tr> <td colspan="4"><input type="hidden" name="category" value="<?php echo $row['category']; ?>" size="25" /></td> </tr> </table> </form> <?php } // doesn't matter if these are outside of the while loop // the way they were defined, it would have the same effect. $_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']; Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 3, 2009 Author Share Posted June 3, 2009 errors happen right around here, Is that really considered cleaned up.. To me it seems more confusing. $sql = <<<QUERY SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = $member_id $limit QUERY; $result = mysql_query($sql) or trigger_error('Select SQL failed.', E_USER_ERROR); Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 3, 2009 Share Posted June 3, 2009 What exactly is the error? <?php session_start(); include "connection.php"; echo '<form id="form2" name="form2" method="get" action="updatetrade.php">'; /*Lol loving the nested PHP tags but that wont work =( and you cant output anything to the screen before session_start(); */ $pageno = isset($_GET['pageno'])? intval($_GET['pageno']) : 1; $findit = intval($_SESSION['id']); $result = mysql_query('SELECT m.id, COUNT(*) AS count FROM abcxyz a INNER JOIN members m ON m.id = a.user_id WHERE m.username="' . $findit .'" LIMIT 1') or trigger_error('User not found.', E_USER_ERROR); $member_info = mysql_fetch_row($result); $member_id = intval($member_info[0]); $numrows = intval($member_info[1]); $rows_per_page = 1; $_SESSION['rid_of_delete_button'] = $lastpage = ceil($numrows/$rows_per_page); $_SESSION['last_page'] = $_SERVER['PHP_SELF']; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) $pageno = $lastpage; else if ($pageno < 1) $pageno = 1; $limit = 'LIMIT '. (($pageno - 1) * $rows_per_page) . ',' . $rows_per_page; $sql = <<<QUERY SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = $member_id $limit; QUERY; $result = mysql_query($sql) or trigger_error('Select SQL failed - ' . mysql_error(), E_USER_ERROR); if ($lastpage === 0) { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; exit; } ?> <table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'> <?php // $dropdown[img_id] = img_name $dropdown = array(); // for performance sake, just run another query even though $sql already selects the data we want. // this will be faster than for PHP to do. $dropdown_sql = 'SELECT id, item_name FROM abcxyz WHERE user_id = ' . $member_id; $dropdown_result = mysql_query($dropdown_sql) or trigger_error('Select SQL failed.', E_USER_ERROR); $dropdown_menu = '<select name="pageno">'; while ($row = mysql_fetch_assoc($dropdown_result)) { $dropdown_menu .= '<option value="' . $row['id'] . '">' . $row['item_name'] . '</option>'; } while ($row = mysql_fetch_assoc($sql)) { $dropdown[$row['id']] = $row['item_name']; echo '<tr>'; for ($e = 2; $e < 6; $e++) { echo '<td width="188" height="180"><div align="center"><img src="' . $row['imgpath'] . '" width="125" alt="image 1" /></div></td><td width="188"><div align="center">'; echo empty($row['imgpath' . $e])? '<a href="picure2.php"><img src="images/uploadanother.png" border="0"></a>' : '<img src="' . $row['imgpath' . $e] . '" width="125" alt="" /><a href="delete_image' . $e . '.php"><span style="color: red;"> X</span></a>'; echo '</div></td>'; } echo '</tr><tr><td height="43" colspan="4"><strong>Item Name:</strong><input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" />  '; echo $pageno == 1? ' Previous Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $prevpage . '"> Previous </a>(' . $pageno . ' of ' . $lastpage . ')'; echo $pageno == $lastpage? ' Next Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $nextpage . '"> Next </a>'; ?> </td> <td><div align="center"><input type="hidden" name="id" value="<?php echo $row['id']; ?>" size="25" /></div></td> </tr> <tr> <td height="116" colspan="4"><strong>Description:</strong> <textarea name="description" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center"><input type="submit" name="submit" id="submit" value="Update Item"></div></td> </tr> <tr> <td height="124" colspan="4"><strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center">'; <?php 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']; } ?> </div><td> </tr> <tr> <td colspan="4"><input type="hidden" name="category" value="<?php echo $row['category']; ?>" size="25" /></td> </tr> </table> </form> <?php } // doesn't matter if these are outside of the while loop // the way they were defined, it would have the same effect. $_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']; Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 3, 2009 Author Share Posted June 3, 2009 error on this line <?php $result = mysql_query($sql) or trigger_error('Select SQL failed - ' . mysql_error(), E_USER_ERROR); ?> Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 3, 2009 Author Share Posted June 3, 2009 Fatal error: Select SQL failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,1' Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 3, 2009 Share Posted June 3, 2009 <?php session_start(); include "connection.php"; echo '<form id="form2" name="form2" method="get" action="updatetrade.php">'; /*Lol loving the nested PHP tags but that wont work =( and you cant output anything to the screen before session_start(); */ $pageno = isset($_GET['pageno'])? intval($_GET['pageno']) : 1; $findit = intval($_SESSION['id']); $result = mysql_query('SELECT m.id, COUNT(*) AS count FROM abcxyz a INNER JOIN members m ON m.id = a.user_id WHERE m.username="' . $findit .'" LIMIT 1') or trigger_error('User not found.', E_USER_ERROR); $member_info = mysql_fetch_row($result); $member_id = intval($member_info[0]); $numrows = intval($member_info[1]); $rows_per_page = 1; $_SESSION['rid_of_delete_button'] = $lastpage = ceil($numrows/$rows_per_page); $_SESSION['last_page'] = $_SERVER['PHP_SELF']; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) $pageno = $lastpage; else if ($pageno < 1) $pageno = 1; $limit = 'LIMIT '. ($pageno * $rows_per_page) . ',' . $rows_per_page; $sql = <<<QUERY SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = $member_id $limit; QUERY; $result = mysql_query($sql) or trigger_error('Select SQL failed - ' . mysql_error(), E_USER_ERROR); if ($lastpage === 0) { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; exit; } ?> <table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'> <?php // $dropdown[img_id] = img_name $dropdown = array(); // for performance sake, just run another query even though $sql already selects the data we want. // this will be faster than for PHP to do. $dropdown_sql = 'SELECT id, item_name FROM abcxyz WHERE user_id = ' . $member_id; $dropdown_result = mysql_query($dropdown_sql) or trigger_error('Select SQL failed.', E_USER_ERROR); $dropdown_menu = '<select name="pageno">'; while ($row = mysql_fetch_assoc($dropdown_result)) { $dropdown_menu .= '<option value="' . $row['id'] . '">' . $row['item_name'] . '</option>'; } while ($row = mysql_fetch_assoc($sql)) { $dropdown[$row['id']] = $row['item_name']; echo '<tr>'; for ($e = 2; $e < 6; $e++) { echo '<td width="188" height="180"><div align="center"><img src="' . $row['imgpath'] . '" width="125" alt="image 1" /></div></td><td width="188"><div align="center">'; echo empty($row['imgpath' . $e])? '<a href="picure2.php"><img src="images/uploadanother.png" border="0"></a>' : '<img src="' . $row['imgpath' . $e] . '" width="125" alt="" /><a href="delete_image' . $e . '.php"><span style="color: red;"> X</span></a>'; echo '</div></td>'; } echo '</tr><tr><td height="43" colspan="4"><strong>Item Name:</strong><input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" />  '; echo $pageno == 1? ' Previous Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $prevpage . '"> Previous </a>(' . $pageno . ' of ' . $lastpage . ')'; echo $pageno == $lastpage? ' Next Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $nextpage . '"> Next </a>'; ?> </td> <td><div align="center"><input type="hidden" name="id" value="<?php echo $row['id']; ?>" size="25" /></div></td> </tr> <tr> <td height="116" colspan="4"><strong>Description:</strong> <textarea name="description" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center"><input type="submit" name="submit" id="submit" value="Update Item"></div></td> </tr> <tr> <td height="124" colspan="4"><strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center">'; <?php 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']; } ?> </div><td> </tr> <tr> <td colspan="4"><input type="hidden" name="category" value="<?php echo $row['category']; ?>" size="25" /></td> </tr> </table> </form> <?php } // doesn't matter if these are outside of the while loop // the way they were defined, it would have the same effect. $_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']; Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 3, 2009 Author Share Posted June 3, 2009 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource on line 238 the commented line below...... <?php $dropdown_sql = 'SELECT id, item_name FROM abcxyz WHERE user_id = ' . $member_id; $dropdown_result = mysql_query($dropdown_sql) or trigger_error('Select SQL failed.', E_USER_ERROR); $dropdown_menu = '<select name="pageno">'; while ($row = mysql_fetch_assoc($dropdown_result)) { $dropdown_menu .= '<option value="' . $row['id'] . '">' . $row['item_name'] . '</option>'; } while ($row = mysql_fetch_assoc($sql)) ////this one ?> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 I'm losing it! Sorry about that. On the line commented, change $sql to $result. Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 4, 2009 Author Share Posted June 4, 2009 Parse error: syntax error, unexpected $end on line 355 which is the very last line of the page. I'll take a look. Is there something in the script you changed that would cause this? Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 4, 2009 Author Share Posted June 4, 2009 Also,, after the closing tag for the form,, you have a new php tag and then a closing bracket.. Is that right? Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 4, 2009 Author Share Posted June 4, 2009 Here is everything from the script to the end of the page <form id="form2" name="form2" method="post" action="updatetrade.php"> <?php session_start(); include "connection.php"; echo '<form id="form2" name="form2" method="get" action="updatetrade.php">'; $pageno = isset($_GET['pageno'])? intval($_GET['pageno']) : 1; $findit = intval($_SESSION['id']); $result = mysql_query('SELECT m.id, COUNT(*) AS count FROM abcxyz a INNER JOIN members m ON m.id = a.user_id WHERE m.username="' . $findit .'" LIMIT 1') or trigger_error('User not found.', E_USER_ERROR); $member_info = mysql_fetch_row($result); $member_id = intval($member_info[0]); $numrows = intval($member_info[1]); $rows_per_page = 1; $_SESSION['rid_of_delete_button'] = $lastpage = ceil($numrows/$rows_per_page); $_SESSION['last_page'] = $_SERVER['PHP_SELF']; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) $pageno = $lastpage; else if ($pageno < 1) $pageno = 1; $limit = 'LIMIT '. ($pageno * $rows_per_page) . ',' . $rows_per_page; $sql = <<<QUERY SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = $member_id $limit; QUERY; $result = mysql_query($sql) or trigger_error('Select SQL failed - ' . mysql_error(), E_USER_ERROR); if ($lastpage === 0) { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; exit; } ?> <table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'> <?php // $dropdown[img_id] = img_name $dropdown = array(); // for performance sake, just run another query even though $sql already selects the data we want. // this will be faster than for PHP to do. $dropdown_sql = 'SELECT id, item_name FROM abcxyz WHERE user_id = ' . $member_id; $dropdown_result = mysql_query($dropdown_sql) or trigger_error('Select SQL failed.', E_USER_ERROR); $dropdown_menu = '<select name="pageno">'; while ($row = mysql_fetch_assoc($dropdown_result)) { $dropdown_menu .= '<option value="' . $row['id'] . '">' . $row['item_name'] . '</option>'; } while ($row = mysql_fetch_assoc($result)) { $dropdown[$row['id']] = $row['item_name']; echo '<tr>'; for ($e = 2; $e < 6; $e++) { echo '<td width="188" height="180"><div align="center"><img src="' . $row['imgpath'] . '" width="125" alt="image 1" /></div></td><td width="188"><div align="center">'; echo empty($row['imgpath' . $e])? '<a href="picure2.php"><img src="images/uploadanother.png" border="0"></a>' : '<img src="' . $row['imgpath' . $e] . '" width="125" alt="" /><a href="delete_image' . $e . '.php"><span style="color: red;"> X</span></a>'; echo '</div></td>'; } echo '</tr><tr><td height="43" colspan="4"><strong>Item Name:</strong><input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" />  '; echo $pageno == 1? ' Previous Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $prevpage . '"> Previous </a>(' . $pageno . ' of ' . $lastpage . ')'; echo $pageno == $lastpage? ' Next Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $nextpage . '"> Next </a>'; ?> </td> <td><div align="center"><input type="hidden" name="id" value="<?php echo $row['id']; ?>" size="25" /></div></td> </tr> <tr> <td height="116" colspan="4"><strong>Description:</strong> <textarea name="description" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center"><input type="submit" name="submit" id="submit" value="Update Item"></div></td> </tr> <tr> <td height="124" colspan="4"><strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center">'; <?php 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']; } ?> </div><td> </tr> <tr> <td colspan="4"><input type="hidden" name="category" value="<?php echo $row['category']; ?>" size="25" /></td> </tr> </table> } </form> <?php $_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']; ?> <form id="form3" name="form3" method="post" action="deletetrade.php"> <div align="center"> <?php $no_trades = $_SESSION['rid_of_delete_button']; if($lastpage != 0) { echo '<input type="submit" name="submit" id="submit" value="Delete Selected Item" />'; } else { echo ""; } ?> </div> <?php if(isset($_SESSION['item_deleted_error'])) { unset($_SESSION['item_deleted']); unset($_SESSION['updateerror']); unset($_SESSION['updatecomplete']); unset($_SESSION['picupload']); echo $_SESSION['item_deleted_error']; } if(isset($_SESSION['item_deleted'])) { unset($_SESSION['item_deleted_error']); unset($_SESSION['item_deleted']); unset($_SESSION['updateerror']); unset($_SESSION['updatecomplete']); unset($_SESSION['picupload']); echo $_SESSION['item_deleted']; } ?> </form> </div> <br /> </td> </tr> </table> <p><br /> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </body> </html> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 <?php session_start(); include "connection.php"; echo '<form id="form2" name="form2" method="get" action="updatetrade.php">'; /*Lol loving the nested PHP tags but that wont work =( and you cant output anything to the screen before session_start(); */ $pageno = isset($_GET['pageno'])? intval($_GET['pageno']) : 1; $findit = intval($_SESSION['id']); $result = mysql_query('SELECT m.id, COUNT(*) AS count FROM abcxyz a INNER JOIN members m ON m.id = a.user_id WHERE m.username="' . $findit .'" LIMIT 1') or trigger_error('User not found.', E_USER_ERROR); $member_info = mysql_fetch_row($result); $member_id = intval($member_info[0]); $numrows = intval($member_info[1]); $rows_per_page = 1; $_SESSION['rid_of_delete_button'] = $lastpage = ceil($numrows/$rows_per_page); $_SESSION['last_page'] = $_SERVER['PHP_SELF']; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) $pageno = $lastpage; else if ($pageno < 1) $pageno = 1; $limit = 'LIMIT '. ($pageno * $rows_per_page) . ',' . $rows_per_page; $sql = <<<QUERY SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = $member_id $limit; QUERY; $result = mysql_query($sql) or trigger_error('Select SQL failed - ' . mysql_error(), E_USER_ERROR); if ($lastpage === 0) { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; exit; } ?> <table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'> <?php // $dropdown[img_id] = img_name $dropdown = array(); // for performance sake, just run another query even though $sql already selects the data we want. // this will be faster than for PHP to do. $dropdown_sql = 'SELECT id, item_name FROM abcxyz WHERE user_id = ' . $member_id; $dropdown_result = mysql_query($dropdown_sql) or trigger_error('Select SQL failed.', E_USER_ERROR); $dropdown_menu = '<select name="pageno">'; while ($row = mysql_fetch_assoc($dropdown_result)) { $dropdown_menu .= '<option value="' . $row['id'] . '">' . $row['item_name'] . '</option>'; } while ($row = mysql_fetch_assoc($sql)) { $dropdown[$row['id']] = $row['item_name']; echo '<tr>'; for ($e = 2; $e < 6; $e++) { echo '<td width="188" height="180"><div align="center"><img src="' . $row['imgpath'] . '" width="125" alt="image 1" /></div></td><td width="188"><div align="center">'; echo empty($row['imgpath' . $e])? '<a href="picure2.php"><img src="images/uploadanother.png" border="0"></a>' : '<img src="' . $row['imgpath' . $e] . '" width="125" alt="" /><a href="delete_image' . $e . '.php"><span style="color: red;"> X</span></a>'; echo '</div></td>'; } echo '</tr><tr><td height="43" colspan="4"><strong>Item Name:</strong><input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" />  '; echo $pageno == 1? ' Previous Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $prevpage . '"> Previous </a>(' . $pageno . ' of ' . $lastpage . ')'; echo $pageno == $lastpage? ' Next Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $nextpage . '"> Next </a>'; ?> </td> <td><div align="center"><input type="hidden" name="id" value="<?php echo $row['id']; ?>" size="25" /></div></td> </tr> <tr> <td height="116" colspan="4"><strong>Description:</strong> <textarea name="description" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center"><input type="submit" name="submit" id="submit" value="Update Item"></div></td> </tr> <tr> <td height="124" colspan="4"><strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center">'; <?php 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']; } ?> </div><td> </tr> <tr> <td colspan="4"><input type="hidden" name="category" value="<?php echo $row['category']; ?>" size="25" /></td> </tr> <?php } ?> </table> </form> <?php // doesn't matter if these are outside of the while loop // the way they were defined, it would have the same effect. $_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']; Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 4, 2009 Author Share Posted June 4, 2009 no errors,, but the script displays nothing at all ,,, not table. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 A bit of debugging then. <?php session_start(); include "connection.php"; echo '<form id="form2" name="form2" method="get" action="updatetrade.php">'; /*Lol loving the nested PHP tags but that wont work =( and you cant output anything to the screen before session_start(); */ $pageno = isset($_GET['pageno'])? intval($_GET['pageno']) : 1; $findit = intval($_SESSION['id']); $result = mysql_query('SELECT m.id, COUNT(*) AS count FROM abcxyz a INNER JOIN members m ON m.id = a.user_id WHERE m.username="' . $findit .'" LIMIT 1') or trigger_error('User not found.', E_USER_ERROR); $member_info = mysql_fetch_row($result); $member_id = intval($member_info[0]); $numrows = intval($member_info[1]); var_dump($member_id, $numrows); $rows_per_page = 1; $_SESSION['rid_of_delete_button'] = $lastpage = ceil($numrows/$rows_per_page); $_SESSION['last_page'] = $_SERVER['PHP_SELF']; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) $pageno = $lastpage; else if ($pageno < 1) $pageno = 1; $limit = 'LIMIT '. ($pageno * $rows_per_page) . ',' . $rows_per_page; $sql = <<<QUERY SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = $member_id $limit; QUERY; $result = mysql_query($sql) or trigger_error('Select SQL failed - ' . mysql_error(), E_USER_ERROR); if ($lastpage === 0) { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; exit; } ?> <table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'> <?php // $dropdown[img_id] = img_name $dropdown = array(); // for performance sake, just run another query even though $sql already selects the data we want. // this will be faster than for PHP to do. $dropdown_sql = 'SELECT id, item_name FROM abcxyz WHERE user_id = ' . $member_id; $dropdown_result = mysql_query($dropdown_sql) or trigger_error('Select SQL failed.', E_USER_ERROR); $dropdown_menu = '<select name="pageno">'; while ($row = mysql_fetch_assoc($dropdown_result)) { $dropdown_menu .= '<option value="' . $row['id'] . '">' . $row['item_name'] . '</option>'; } while ($row = mysql_fetch_assoc($sql)) { $dropdown[$row['id']] = $row['item_name']; echo '<tr>'; for ($e = 2; $e < 6; $e++) { echo '<td width="188" height="180"><div align="center"><img src="' . $row['imgpath'] . '" width="125" alt="image 1" /></div></td><td width="188"><div align="center">'; echo empty($row['imgpath' . $e])? '<a href="picure2.php"><img src="images/uploadanother.png" border="0"></a>' : '<img src="' . $row['imgpath' . $e] . '" width="125" alt="" /><a href="delete_image' . $e . '.php"><span style="color: red;"> X</span></a>'; echo '</div></td>'; } echo '</tr><tr><td height="43" colspan="4"><strong>Item Name:</strong><input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" />  '; echo $pageno == 1? ' Previous Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $prevpage . '"> Previous </a>(' . $pageno . ' of ' . $lastpage . ')'; echo $pageno == $lastpage? ' Next Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $nextpage . '"> Next </a>'; ?> </td> <td><div align="center"><input type="hidden" name="id" value="<?php echo $row['id']; ?>" size="25" /></div></td> </tr> <tr> <td height="116" colspan="4"><strong>Description:</strong> <textarea name="description" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center"><input type="submit" name="submit" id="submit" value="Update Item"></div></td> </tr> <tr> <td height="124" colspan="4"><strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center">'; <?php 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']; } ?> </div><td> </tr> <tr> <td colspan="4"><input type="hidden" name="category" value="<?php echo $row['category']; ?>" size="25" /></td> </tr> <?php } ?> </table> </form> <?php // doesn't matter if these are outside of the while loop // the way they were defined, it would have the same effect. $_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']; Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 4, 2009 Author Share Posted June 4, 2009 int(0) int(0) Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 4, 2009 Author Share Posted June 4, 2009 I tried a few things and couldn't get it to work... I'll just change the way this is done using 2 pages for now. I'll keep this open incase you do have sometime to mess around with it. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 Sorry for the delay. I was busy with something else. Okay so for some reason, the SQL isn't picking up any user data. <?php session_start(); include "connection.php"; echo '<form id="form2" name="form2" method="get" action="updatetrade.php">'; /*Lol loving the nested PHP tags but that wont work =( and you cant output anything to the screen before session_start(); */ $pageno = isset($_GET['pageno'])? intval($_GET['pageno']) : 1; $findit = intval($_SESSION['id']); $sql = 'SELECT m.id, COUNT(*) AS count FROM abcxyz a RIGHT OUTER JOIN members m ON m.id = a.user_id WHERE m.username="' . $findit .'" LIMIT 1'; var_dump($sql); $result = mysql_query($sql) or trigger_error('User not found.', E_USER_ERROR); $member_info = mysql_fetch_row($result); $member_id = intval($member_info[0]); $numrows = intval($member_info[1]); $rows_per_page = 1; $_SESSION['rid_of_delete_button'] = $lastpage = ceil($numrows/$rows_per_page); $_SESSION['last_page'] = $_SERVER['PHP_SELF']; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) $pageno = $lastpage; else if ($pageno < 1) $pageno = 1; $limit = 'LIMIT '. ($pageno * $rows_per_page) . ',' . $rows_per_page; $sql = <<<QUERY SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = $member_id $limit; QUERY; $result = mysql_query($sql) or trigger_error('Select SQL failed - ' . mysql_error(), E_USER_ERROR); if ($lastpage === 0) { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; exit; } ?> <table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'> <?php // $dropdown[img_id] = img_name $dropdown = array(); // for performance sake, just run another query even though $sql already selects the data we want. // this will be faster than for PHP to do. $dropdown_sql = 'SELECT id, item_name FROM abcxyz WHERE user_id = ' . $member_id; $dropdown_result = mysql_query($dropdown_sql) or trigger_error('Select SQL failed.', E_USER_ERROR); $dropdown_menu = '<select name="pageno">'; while ($row = mysql_fetch_assoc($dropdown_result)) { $dropdown_menu .= '<option value="' . $row['id'] . '">' . $row['item_name'] . '</option>'; } while ($row = mysql_fetch_assoc($sql)) { $dropdown[$row['id']] = $row['item_name']; echo '<tr>'; for ($e = 2; $e < 6; $e++) { echo '<td width="188" height="180"><div align="center"><img src="' . $row['imgpath'] . '" width="125" alt="image 1" /></div></td><td width="188"><div align="center">'; echo empty($row['imgpath' . $e])? '<a href="picure2.php"><img src="images/uploadanother.png" border="0"></a>' : '<img src="' . $row['imgpath' . $e] . '" width="125" alt="" /><a href="delete_image' . $e . '.php"><span style="color: red;"> X</span></a>'; echo '</div></td>'; } echo '</tr><tr><td height="43" colspan="4"><strong>Item Name:</strong><input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" />  '; echo $pageno == 1? ' Previous Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $prevpage . '"> Previous </a>(' . $pageno . ' of ' . $lastpage . ')'; echo $pageno == $lastpage? ' Next Item ' : '<a href="' . $_SERVER['PHP_SELF'] . '"?pageno=' . $nextpage . '"> Next </a>'; ?> </td> <td><div align="center"><input type="hidden" name="id" value="<?php echo $row['id']; ?>" size="25" /></div></td> </tr> <tr> <td height="116" colspan="4"><strong>Description:</strong> <textarea name="description" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center"><input type="submit" name="submit" id="submit" value="Update Item"></div></td> </tr> <tr> <td height="124" colspan="4"><strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5"><?php echo $row['description']; ?></textarea></td> <td><div align="center">'; <?php 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']; } ?> </div><td> </tr> <tr> <td colspan="4"><input type="hidden" name="category" value="<?php echo $row['category']; ?>" size="25" /></td> </tr> <?php } ?> </table> </form> <?php // doesn't matter if these are outside of the while loop // the way they were defined, it would have the same effect. $_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']; Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 4, 2009 Author Share Posted June 4, 2009 string(127) "SELECT m.id, COUNT(*) AS count FROM abcxyz a RIGHT OUTER JOIN members m ON m.id = a.user_id WHERE m.username="0" LIMIT 1" Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 6, 2009 Share Posted June 6, 2009 So the username is 0? Quote Link to comment Share on other sites More sharing options...
justAnoob Posted June 6, 2009 Author Share Posted June 6, 2009 sorry for the late reply,, kids are sick today.. I catch you sometime this weekend.... thans for looking out though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.