Jump to content

smproph

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Everything posted by smproph

  1. From if($_POST['Initials']) { $Initials=$_POST['Initials']; $qry_str.=' and Initials LIKE "%'.$Initials . '%"'; } if($_POST['Identifier']) { $Identifier=$_POST['Identifier']; $qry_str.=' and Identifier LIKE "%'.$Identifier . '%"'; } if($_POST['Type']) { $Type=$_POST['Type']; $qry_str.=' and Type LIKE "%'.$Type . '%"'; } if($_POST['Terms']) { $Terms=$_POST['Terms']; $qry_str.=' and Terms LIKE "%'.$Terms . '%"'; } if($_POST['Memo']) { $Memo=$_POST['Memo']; $qry_str.=' and Memo LIKE "%'.$Memo . '%"'; } if($_POST['date1']) { $date1=$_POST['date1']; $date2=$_POST['date2']; $start=date('Y-m-d', strtotime($date1)); $end=date('Y-m-d', strtotime($date2)); $qry_str.=' and Date >= $start and Date <= $end '; } This takes data from the form on the previous search page <table width="100%" class="tablefont"> <tr><td align="center">Search Timeslips<br/><img src="images/time.png" height="60px"></td> <td align="center">Search Tasks<br/><img src="images/task.png" height="60px"></td> <td align="center">Search Clients<br/><img src="images/client.png" height="60px"></td></tr> <tr><td><br/></td></tr> <tr> <td valign="top"> <table class="tablefont" align="center"> <form action="searchresults.php" method="post" name="search"> <tr> <td align="right">Initials</td><td><SELECT NAME=Initials> <OPTION value="">Select</OPTION> <OPTION value="AAC">AAC</OPTION> <OPTION value="AJP">AJP</OPTION> <OPTION value="EJG">EJG</OPTION> <OPTION value="FAH">FAH</OPTION> <OPTION value="GEC">GEC</OPTION> <OPTION value="IJC">IJC</OPTION> <OPTION value="KHW">KHW</OPTION> <OPTION value="LH">LH</OPTION> <OPTION value="VRT">VRT</OPTION> </SELECT></td> </tr> <tr><td align="right">Identifier</td><td><input type="text" name="Identifier" id="course" /></td></tr> <tr><td align="right">Type </td><td> <SELECT NAME=Type> <option value="">Select</option> <OPTION value="Attendance">Attendance</OPTION> <OPTION value="Correspondence">Correspondence</OPTION> <OPTION value="Intake">Intake</OPTION> <OPTION value="IPC">IPC</OPTION> <OPTION value="Meeting">Meeting</OPTION> <OPTION value="Mess Done">Mess Done</OPTION> <OPTION value="Mess New">Mess New</OPTION> <OPTION value="Note">Note</OPTION> <OPTION value="OPC">OPC</OPTION> <OPTION value="Research">Research</OPTION> <OPTION value="Review">Review</OPTION> <OPTION value="RPC">RPC</OPTION> </SELECT></td> </tr> <tr><td align="right">Memo</td> <td><input type="text" name="Memo" /></td> </tr> <tr><td align="right">Terms</td><td> <SELECT NAME=Terms> <option value="">Select</option> <OPTION value="Appt">Appt</OPTION> <OPTION value="BK13">BK13</OPTION> <OPTION value="BK7">BK7</OPTION> <OPTION value="Cont">Cont</OPTION> <OPTION value="FRT">FRT</OPTION> <OPTION value="HRD">HRD</OPTION> <OPTION value="HRB">HRB</OPTION> <OPTION value="HRT">HRT</OPTION> <OPTION value="Intake">Intake</OPTION> <OPTION value="NC">NC</OPTION> </SELECT></td></tr> <tr align="center"><td colspan="2">Date Range</td></tr> <tr><td align="right"> <script language="JavaScript"> new tcal ({ // form name 'formname': 'search', // input name 'controlname': 'date1' }); </script> <input placeholder="12/12/2012" type="text" name="date1" size="10"/> </td> <td align="right"> <script language="JavaScript"> new tcal ({ // form name 'formname': 'search', // input name 'controlname': 'date2' }); </script> <input placeholder="12/13/2012" type="text" name="date2" size="10"/> </td> </tr> <tr><td><div id="calendar"></div></td></tr> <tr><td align="right"><INPUT TYPE="button" VALUE="Empty Fields" onClick="parent.location='search.php'"></td> <td align="left"> <input type="submit" name="submit" value="Search" /></td></tr> </form> </table> This part of the IF's: if($_POST['order1'] && $_POST['order2']) { $order1=$_POST['order1']; $order2=$_POST['order2']; $qry_str=$_POST['qry']; $qry_str=' '.$qry_str . ' ORDER BY "'.$order1 . '" ASC, "'.$order2 . '" ASC '; } elseif(isset($_POST['order1'])) { $order1=$_POST['order1']; $qry=$_POST['qry']; $qry_str='$qry ORDER BY $order1 ASC'; } else { if(isset($_POST['order2'])) { $order2=$_POST['order1']; $qry=$_POST['qry']; $qry_str='$qry ORDER BY $order2 ASC'; } } if( !$result = mysql_query($qry_str) ) { echo "<br>Query string: $qry_str<br>Failed with error: " . mysql_error() . '<br>'; echo $qry_str; } else { $result=mysql_query($qry_str); $count=mysql_num_rows($result); if ($count>0){ $newqry ='SELECT * FROM timeslip WHERE 1 and Initials LIKE "%GEC%" and Type LIKE "%IPC%" and Terms LIKE "%HRT%"'; echo $newqry; ?> takes from this form <form action="" method="post"> <input type="hidden" value="<?=$newqry?>" name="qry"/> Order Results By <select name="order1" > <OPTION value="<?=$order1?>"><?=$order1?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> Then <select name="order2" > <OPTION value="<?=$order2?>"><?=$order2?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> <input type="submit" name="submit"> </form>
  2. Maybe there is just a better way for me to do this. I have it where search results pull up after they search and then on the Searchresults page they can order by 2 different fields. Is there a better way other than making it a form on the Searchresults page and submitting their results. Because by putting the SELECT statment in a hidden field on the Form I am some how losing the value of what they originally searched by.
  3. I am getting a value on $_POST['Initials']. My search works great. It is just after the user searches and gets to the results page you have two drop down menus on top. Those drop down menus is what you can order by. When a user selects two categories to Order By and clicks submit, the form on the results page just sends to the same page whatever the user selected and I add those variables to the end of the Select Statement and use Order By. I am sending the Select statement as a hidden input with the form so whatever the user originally searched for on the previous page is not lost. That's why I have : <form action="" method="post"> <input type="hidden" value="<?=$qry_str?>" name="qry"/> Order Results By <select name="order1" > <OPTION value="<?=$order1?>"><?=$order1?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> Then <select name="order2" > <OPTION value="<?=$order2?>"><?=$order2?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> <input type="submit" name="submit"> </form> And then my IF statement determines if they just posted that Order By data: if($_POST['order1'] && $_POST['order2']) { $order1=$_POST['order1']; $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str=' "'.$qry.'" ORDER BY "'.$order1 . '" ASC, "'.$order2 . '" ASC '; }
  4. I seem to be losing the value. Echo brings back nothing. My goal is to allow the user, after he searches from something to be able to order by two other categories. Here is the form with my code on top that I posted. I don't see why I am losing the value since on the form, I took the entire SELECT statement that the server queried with and then sent it back to the page with just adding the Order by statement on the end of it. $qry_str="SELECT * FROM timeslip WHERE 1 "; if($_POST['Initials']) { $Initials=$_POST['Initials']; $qry_str.='and Initials="'.$Initials . '"'; } if($_POST['Identifier']) { $Identifier=$_POST['Identifier']; $qry_str.='and Identifier LIKE "%'.$Identifier . '%"'; } if($_POST['Type']) { $Type=$_POST['Type']; $qry_str.='and Type LIKE "%'.$Type . '%"'; } if($_POST['Terms']) { $Terms=$_POST['Terms']; $qry_str.='and Terms LIKE "%'.$Terms . '%"'; } if($_POST['Memo']) { $Memo=$_POST['Memo']; $qry_str.='and Memo LIKE "%'.$Memo . '%"'; } if($_POST['date1']) { $date1=$_POST['date1']; $date2=$_POST['date2']; $start=date('Y-m-d', strtotime($date1)); $end=date('Y-m-d', strtotime($date2)); $qry_str.="and Date >= $start and Date <= $end "; } if($_POST['order1'] && $_POST['order2']) { $order1=$_POST['order1']; $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str=' "'.$qry.'" ORDER BY "'.$order1 . '" ASC, "'.$order2 . '" ASC '; } elseif(isset($_POST['order1'])) { $order1=$_POST['order1']; $qry=$_POST['qry']; $qry_str='$qry ORDER BY $order1 ASC'; } else { if(isset($_POST['order2'])) { $order2=$_POST['order1']; $qry=$_POST['qry']; $qry_str='$qry ORDER BY $order2 ASC'; } } if( !$result = mysql_query($qry_str) ) { echo "<br>Query string: $qry_str<br>Failed with error: " . mysql_error() . '<br>'; echo "Hi ".$Initials; } else { $result=mysql_query($qry_str); $count=mysql_num_rows($result); if ($count>0){ ?> <form action="" method="post"> <input type="hidden" value="<?=$qry_str?>" name="qry"/> Order Results By <select name="order1" > <OPTION value="<?=$order1?>"><?=$order1?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> Then <select name="order2" > <OPTION value="<?=$order2?>"><?=$order2?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> <input type="submit" name="submit"> </form>
  5. I am not sure If I am loosing my variable or if it is just getting cancelled out by the syntax. The error I get is this: Query string: "SELECT * FROM timeslip WHERE 1 and Initials=" ORDER BY "Date" ASC, "Cost" ASC Failed with error: 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 '"SELECT * FROM timeslip WHERE 1 and Initials=" ORDER BY "Date" ASC, "Cost" ASC' at line 1 Initials should have the value of GEC at this moment Here is my code: $qry_str="SELECT * FROM timeslip WHERE 1 "; if($_POST['Initials']) { $Initials=$_POST['Initials']; $qry_str.='and Initials="'.$Initials . '"'; } if($_POST['Identifier']) { $Identifier=$_POST['Identifier']; $qry_str.='and Identifier LIKE "%'.$Identifier . '%"'; } if($_POST['Type']) { $Type=$_POST['Type']; $qry_str.='and Type LIKE "%'.$Type . '%"'; } if($_POST['Terms']) { $Terms=$_POST['Terms']; $qry_str.='and Terms LIKE "%'.$Terms . '%"'; } if($_POST['Memo']) { $Memo=$_POST['Memo']; $qry_str.='and Memo LIKE "%'.$Memo . '%"'; } if($_POST['date1']) { $date1=$_POST['date1']; $date2=$_POST['date2']; $start=date('Y-m-d', strtotime($date1)); $end=date('Y-m-d', strtotime($date2)); $qry_str.="and Date >= $start and Date <= $end "; } if($_POST['order1'] && $_POST['order2']) { $order1=$_POST['order1']; $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str=' "'.$qry.'" ORDER BY "'.$order1 . '" ASC, "'.$order2 . '" ASC '; } elseif(isset($_POST['order1'])) { $order1=$_POST['order1']; $qry=$_POST['qry']; $qry_str='$qry ORDER BY $order1 ASC'; } else { if(isset($_POST['order2'])) { $order2=$_POST['order1']; $qry=$_POST['qry']; $qry_str='$qry ORDER BY $order2 ASC'; } } if( !$result = mysql_query($qry_str) ) { echo "<br>Query string: $qry_str<br>Failed with error: " . mysql_error() . '<br>'; }
  6. Okay, I think I am almost there. But for some reason I am losing my $qry data. Here is the code and error. Look after Initials and you see '' instead of actual initials. Query string: "SELECT * FROM timeslip WHERE 1 and Initials=" ORDER BY "Date" ASC, "Cost" ASC Failed with error: 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 '"SELECT * FROM timeslip WHERE 1 and Initials=" ORDER BY "Date" ASC, "Cost" ASC' at line 1 if($_POST['Initials']) { $Initials=$_POST['Initials']; $qry_str.='and Initials="'.$Initials . '"'; } if($_POST['Identifier']) { $Identifier=$_POST['Identifier']; $qry_str.='and Identifier LIKE "%'.$Identifier . '%"'; } if($_POST['Type']) { $Type=$_POST['Type']; $qry_str.='and Type LIKE "%'.$Type . '%"'; } if($_POST['Terms']) { $Terms=$_POST['Terms']; $qry_str.='and Terms LIKE "%'.$Terms . '%"'; } if($_POST['Memo']) { $Memo=$_POST['Memo']; $qry_str.='and Memo LIKE "%'.$Memo . '%"'; } if($_POST['date1']) { $date1=$_POST['date1']; $date2=$_POST['date2']; $start=date('Y-m-d', strtotime($date1)); $end=date('Y-m-d', strtotime($date2)); $qry_str.="and Date >= $start and Date <= $end "; } if($_POST['order1'] && $_POST['order2']) { $order1=$_POST['order1']; $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str=' "'.$qry.'" ORDER BY "'.$order1 . '" ASC, "'.$order2 . '" ASC ';
  7. The If, Else If statement worked great. Now the only problem I see left is the double single quote problem. It keeps adding " ' " on both sides of my variables I am searching for. Would I need to escape the single quotes some how?
  8. How would I logically write it to where if only 1st value is submitted then do that, if both are submitted then do that
  9. After changing it, it seems when I am echoing the qry_str that it is using all 3 if's. Here is the error Query string: SELECT * FROM timeslip WHERE 1 ORDER BY Date ASC, Cost ASC ORDER BY Date ASCORDER BY Cost ASC Failed with error: 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 'ORDER BY Date ASCORDER BY Cost ASC' at line 1 It is supposed to do the 1st IF, if the user chooses to sort by two. Uses second IF if he decides to sort by 1, and 3rd IF if user decides to choose by only the 2nd dropdown if($_POST['order1'] && $_POST['order2']) { $order1=$_POST['order1']; $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str.="ORDER BY $order1 ASC, $order2 ASC "; } if($_POST['order1']) { $order1=$_POST['order1']; $qry=$_POST['qry']; $qry_str.="ORDER BY $order1 ASC"; } if($_POST['order2']) { $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str.="ORDER BY $order2 ASC "; }
  10. This is the error I am getting: Query string: SELECT * FROM timeslip WHERE 1 and Initials=''GEC'' and Type LIKE ''%IPC%'' and Terms LIKE ''%HRT%'' ORDER BY Cost ASC Failed with error: 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 'GEC'' and Type LIKE ''%IPC%'' and Terms LIKE ''%HRT%'' ORDER BY Cost ASC' at line 1 $order1 and $order2 are the selections the user is choosing to order by.
  11. Well I am wanting to overwrite it when they do the order because the $_POST for their Order By has the SELECT statement from when they first searched already in it. i.e. $qry ORDER BY $order2 ASC. $qry is the SELECT statement originally used. I did add the '.' to see what it did and it did not work, same error. Just doubles my SELECT statement
  12. Currently I have where the User can search for records, then the records are displayed on a page. I then have a drop down box to where the user can Order by 2 different categories to make it easier for the user to see things but for some reason it is not working. Here is my code. Oh and the error I get is mysql_num_rows(): supplied argument is not a valid MySQL result resource in <?php $qry_str="SELECT * FROM timeslip WHERE 1 "; if($_POST['Initials']) { $Initials=$_POST['Initials']; $qry_str.="and Initials='$Initials' "; } if($_POST['Identifier']) { $Identifier=$_POST['Identifier']; $qry_str.="and Identifier LIKE '%$Identifier%' "; } if($_POST['Type']) { $Type=$_POST['Type']; $qry_str.="and Type LIKE '%$Type%' "; } if($_POST['Terms']) { $Terms=$_POST['Terms']; $qry_str.="and Terms LIKE '%$Terms%' "; } if($_POST['Memo']) { $Memo=$_POST['Memo']; $qry_str.="and Memo LIKE '%$Memo%' "; } if($_POST['date1']) { $date1=$_POST['date1']; $date2=$_POST['date2']; $start=date('Y-m-d', strtotime($date1)); $end=date('Y-m-d', strtotime($date2)); $qry_str.="and Date >= '$start' and Date <= '$end' "; } if($_POST['order1'] && $_POST['order2']) { $order1=$_POST['order1']; $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str="$qry ORDER BY $order1 ASC, $order2 ASC "; } if($_POST['order1']) { $order1=$_POST['order1']; $qry=$_POST['qry']; $qry_str="$qry ORDER BY $order1 ASC"; } if($_POST['order2']) { $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str="$qry ORDER BY $order2' ASC "; } $result=mysql_query($qry_str); $count=mysql_num_rows($result); if ($count>0){ ?> <form action="" method="post"> <input type="hidden" value="<?=$qry_str?>" name="qry"/> Order Results By <select name="order1" > <OPTION value="<?=$order1?>"><?=$order1?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> Then <select name="order2" > <OPTION value="<?=$order2?>"><?=$order2?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> <input type="submit" name="submit"> </form>
  13. Links to pages incase you want to seem them there: http://frankahinojosa.com/salawyer/test.php http://frankahinojosa.com/salawyer/searchresults.php I am trying to figure out how come this code will work on this 1st page but it won't work on this page. Here is the code <script type="text/javascript" src="javascript/jquery-1.4.4.js"></script> <script type="text/javascript" src="javascript/table.js"></script> <title>Untitled Document</title> <link rel="stylesheet" href="css/styles_screen.css" type ="text/css" media="screen"> <link rel="stylesheet" href="css/typography.css" type ="text/css" media="screen"> <link rel="stylesheet" href="css/styles_print.css" type ="text/css" media="print"> <link rel="stylesheet" href="css/table.css" type ="text/css" media="print"> </head> <body> <table class="example table-autosort:4 table-stripeclass:alternate"> <thead> <tr> <th class="table-sortable:numeric">Index</th> <th class="table-sortable:numeric">Numeric</th> <th class="table-sortable:default">Text</th> <th class="table-sortable:currency">Currency</th> <th class="table-sortable:date">Date</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>287.5</td> <td>Bill</td> <td>$7.93</td> <td>2013-10-06</td> </tr> <tr> <td>1</td> <td>529.6</td> <td>Joe</td> <td>$94.74</td> <td>2012-07-08</td> </tr> </tbody> </table> </body> But here it won't work <script type="text/javascript" src="javascript/jquery-1.4.4.js"></script> <script type="text/javascript" src="javascript/table.js"></script> <title>Untitled Document</title> <link rel="stylesheet" href="css/styles_screen.css" type ="text/css" media="screen"> <link rel="stylesheet" href="css/typography.css" type ="text/css" media="screen"> <link rel="stylesheet" href="css/styles_print.css" type ="text/css" media="print"> <link rel="stylesheet" href="css/table.css" type ="text/css" media="print"> </head> <body> <div id="wrapper"> <div id="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="autoselect/timeslip.php">New Timeslip</a></li> <li><a href="tasks.php">New Task</a></li> <li><a href="newclient.php">New Client</a></li> <li><a href="search.php">Search</a></li> <li><a href="login/logout.php">Logout</a></li> </ul></div> <div id="content"> <FORM><INPUT TYPE="button" VALUE="Refine Search" onClick="history.go(-1);return true;"></FORM> <?php mysql_connect ("*", "*","*") or die (mysql_error()); mysql_select_db ("*"); $qry_str="SELECT * FROM tasks WHERE 1 "; if($_POST['Owner']) { $Owner=$_POST['Owner']; $qry_str.="and Owner='$Owner' "; } if($_POST['Identifier']) { $Identifier=$_POST['Identifier']; $qry_str.="and Identifier LIKE '%$Identifier%' "; } if($_POST['Staff']) { $Staff=$_POST['Staff']; $qry_str.="and Staff='$Staff' "; } if($_POST['Priority']) { $Priority=$_POST['Priority']; $qry_str.="and Priority='$Priority' "; } if($_POST['Status']) { $Status=$_POST['Status']; $qry_str.="and Status LIKE '%$Status%' "; } if($_POST['Description']) { $Description=$_POST['Description']; $qry_str.="and Description LIKE '%$Description%' "; } if($_POST['start1']) { $start1=$_POST['start1']; $start2=$_POST['start2']; $start=date('Y-m-d', strtotime($start1)); $end=date('Y-m-d', strtotime($start2)); $qry_str.="and start >= '$start' and start <= '$end' "; } if($_POST['end1']) { $end1=$_POST['end1']; $end2=$_POST['end2']; $start=date('Y-m-d', strtotime($end1)); $end=date('Y-m-d', strtotime($end2)); $qry_str.="and due >= '$start' and due <= '$end' "; } $result=mysql_query($qry_str); $count=mysql_num_rows($result); if ($count>0){ ?> <form name="del" action="deletetask.php" method="POST"> <table class="table-autostripe"> <thead> <tr><th width="1px"></th> <th style="text-align:left;" width="40px">Edit</th> <th width="35px" class="table-sortable:default" align="left">Ini</th> <th width="40px" class="table-sortable:default" align="left">Staff</th> <th width="200px" class="table-sortable:default" align="left">Identifier</th> <th width="100px" class="table-sortable:date" align="left">Due</th> <th width="35px" class="table-sortable:numeric" align="left">Pri</th> <th width="130px" class="table-sortable:default" align="left">Status</th> <th width="350px" class="table-sortable:default" align="left">Description</th> </tr> </thead> <tbody> <? while ($row = mysql_fetch_array($result)){ $rid=$row['task_id']; $rowner=$row['owner']; $rstaff=$row['staff']; $rident=$row['identifier']; $rdate=$row['due']; $rpriority=$row['priority']; $rstatus=$row['status']; $rdesc=$row['description']; ?> <tr> <td valign="top"></td> <td valign="top"> <a href="edittask.php?edata=<?=$rid?>"><img src="images/pencil.png" height="24px" width="24px"/></a></td> <td valign="top" align="left"><?=$rowner?></td> <td valign="top" align="left"><?=$rstaff?></td> <td valign="top" align="left"><?php echo substr($rident,0,40);?></td> <td valign="top" align="left"> <?php $convdate = date('m/d/Y', strtotime($rdate));?> <?=$convdate?></td> <td valign="top" align="left"><?=$rpriority?></td> <td valign="top" align="left"><?=$rstatus?></td> <td valign="top" align="left"><?php echo substr($rdesc,0,40);?></td> <td align="center"> <input type="checkbox" name="del[]" id="del" value="<?=$row['task_id']?>"></td> </tr> <? } ?> <tr> <td colspan="10" align="center"><input type="submit" name="justdel" value="Delete" id="justdel"></td> </tr> </tbody> </table> </form> <? } else { echo 'No Records Returned'; } ?> </div> <div id="footer"> <div id="footertext">Powered and Designed by pr0phet/b0mber Creations</div> </div> </div> </body>
  14. Ok couldn't figure out how to edit my last post. Here is what I need to accomplish. I have two forms, Edit and Delete. My while loop is creating an Edit form for every record. Problem is I am also putting a checkbox input inside the WHILE loop which is not apart of the Edit Form. The checkboxes are apart of the Delete form, which the submit button is outside the WHILE loop. I know you can't have a form inside a form. Any ideas on how I can get around this problem? My overall goal is that I am trying to be able to Edit and Delete my records.
  15. The closing form was at the very end. Guess you can't really have a form inside a form. How would I get around this because I need the two input values to be apart of a form separate from my Edit form. The while loop is what is throwing me off because some of the form i.e. the check boxes to select which ones you want to delete and in the loop and the actual DELETE submit button is outside the loop. <form action="edittask.php" name="<?=$rid?>" method="post"> <input type="hidden" name="edata" value="<?=$rid?>"> </form> <a href="#" onclick="document['<?=$rid?>'].submit()"><img src="images/pencil.png" height="24px" width="24px"/></a></td> <td valign="top" align="left"><?=$rowner?></td> <td valign="top" align="left"><?=$rstaff?></td> <td valign="top" align="left"><?=$rident?></td> <td valign="top" align="left"> <?php $convdate = date('m/d/Y', strtotime($rdate));?> <?=$convdate?></td> <td valign="top" align="left"><?=$rpriority?></td> <td valign="top" align="left"><?=$rstatus?></td> <td valign="top" align="left"><?=$rdesc?></td> <td align="center">[color=yellow]<input type="checkbox" name="del[]" id="del" value="<?=$row['task_id']?>">[/color]</td> </tr> <? } ?> </tbody> <tbody> <tr> <td colspan="10" align="center">[color=yellow]<input type="submit" name="justdel" value="Delete" id="justdel">[/color]</td></tr></td>
  16. Okay so after using Firefox Error Console, it is saying that document[13] is undefined. Not sure if that helps.
  17. That's my code for my Search Results page <?php mysql_connect ("***", "***","***") or die (mysql_error()); mysql_select_db ("***"); $qry_str="SELECT * FROM tasks WHERE 1 "; if($_POST['Owner']) { $Owner=$_POST['Owner']; $qry_str.="and Owner='$Owner' "; } if($_POST['Identifier']) { $Identifier=$_POST['Identifier']; $qry_str.="and Identifier LIKE '%$Identifier%' "; } if($_POST['Staff']) { $Staff=$_POST['Staff']; $qry_str.="and Staff='$Staff' "; } if($_POST['Date']) { $Date=$_POST['Date']; $qry_str.="and Date LIKE '%$Date%' "; } if($_POST['Priority']) { $Priority=$_POST['Priority']; $qry_str.="and Priority='$Priority' "; } if($_POST['Status']) { $Status=$_POST['Status']; $qry_str.="and Status LIKE '%$Status%' "; } if($_POST['Description']) { $Description=$_POST['Description']; $qry_str.="and Description LIKE '%$Description%' "; } if($_POST['start1']) { $start1=$_POST['start1']; $start2=$_POST['start2']; $start=date('Y-m-d', strtotime($start1)); $end=date('Y-m-d', strtotime($start2)); $qry_str.="and start >= '$start' and start <= '$end' "; } if($_POST['end1']) { $end1=$_POST['end1']; $end2=$_POST['end2']; $start=date('Y-m-d', strtotime($end1)); $end=date('Y-m-d', strtotime($end2)); $qry_str.="and due >= '$start' and due <= '$end' "; } ?> <form action="deletetask.php" method="POST"> <table class="example table-autostripe table-rowshade-alternate"> <thead> <tr><th width="1px"></th> <th style="text-align:left;" width="40px">Edit</th> <th width="70px" class="table-sortable:default" align="left">Initials</th> <th width="70px" class="table-sortable:default" align="left">Staff</th> <th width="150px" class="table-sortable:default" align="left">Identifier</th> <th width="100px" class="table-sortable:date" align="left">Due</th> <th width="35px" class="table-sortable:numeric" align="left">Pri</th> <th width="140px" class="table-sortable:default" align="left">Status</th> <th width="350px" class="table-sortable:default" align="left">Description</th> </tr> </thead> <tbody> <? $result=mysql_query($qry_str); $count=mysql_num_rows($result); while ($row = mysql_fetch_array($result)){ $rid=$row['task_id']; $rowner=$row['owner']; $rstaff=$row['staff']; $rident=$row['identifier']; $rdate=$row['due']; $rpriority=$row['priority']; $rstatus=$row['status']; $rdesc=$row['description']; ?> <tr> <td valign="top"></td> <td valign="top"> <form action="edittask.php" name="<?=$rid?>" method="post"> <input type="hidden" name="edata" value="<?=$rid?>"> </form> <a href="#" onclick="document['<?=$rid?>'].submit()"><img src="images/pencil.png" height="24px" width="24px"/></a></td> <td valign="top" align="left"><?=$rowner?></td> <td valign="top" align="left"><?=$rstaff?></td> <td valign="top" align="left"><?=$rident?></td> <td valign="top" align="left"> <?php $convdate = date('m/d/Y', strtotime($rdate));?> <?=$convdate?></td> <td valign="top" align="left"><?=$rpriority?></td> <td valign="top" align="left"><?=$rstatus?></td> <td valign="top" align="left"><?=$rdesc?></td> <td align="center"><input type="checkbox" name="del[]" id="del" value="<?=$row['task_id']?>"></td> </tr> <? } ?> </tbody> <tbody> <tr> <td colspan="10" align="center"><input type="submit" name="justdel" value="Delete" id="justdel"></td></tr></td> </tr> </tbody> </table> </form>
  18. Okay so I used firebug and noticed that my first record looks like this <td> <input type="hidden" value "13" name="edata"> <a onclick="document['13'].submit()" href="#"> <img width="24px" height="24px" src="images/pencil.png"> </a> And the second record is returning... <td> <form method="post" name="14" action="edittask.php"> <input type="hidden" value "14" name="edata"> </form> <a onclick="document['14'].submit()" href="#"> <img width="24px" height="24px" src="images/pencil.png"> </a> Why is my php writing the form for the 2nd record but not the 1st one? Any ideas?
  19. When it gives you the error right there and points to the mysql query it is usually the SELECT query you are using that is the problem. At least in my cases it usually is. Could you copy and paste you SELECT statement you are using?
  20. I have a search that the user can use and pulls up the records from the database. I made it to where you can click on an image and it will let you edit that record, problem is, it won't let me edit the 1st record that is populated, the rest work fine. Can you find what I am doing wrong? while ($row = mysql_fetch_array($result)) { $rid=$row['timeslip_id']; $rint=$row['Initials']; $rident=$row['Identifier']; $rtype=$row['Type']; $rterms=$row['Terms']; $rmemo=$row['Memo']; $rdate=$row['Date']; $rcost=$row['Cost']; ?> <tr> <td valign="top"></td> <td valign="top"> <form action="editslip.php" name="<?=$rid?>" method="post"> <input type="hidden" name="edata" value="<?=$rid?>"> </form> <a href="#" onclick="document['<?=$rid?>'].submit()"><img src="images/pencil.png" height="24px" width="24px"/></a></td> <td valign="top" align="left"><?=$rint?></td> <td valign="top" align="left"><?=$rident?></td> <td valign="top" align="left"><?=$rtype?></td> <td valign="top" align="left"><?=$rterms?></td> <td valign="top" align="left"> <?php $convdate = date('m/d/Y', strtotime($rdate));?> <?=$convdate?></td> <td valign="top"><?=$rcost?></td> <td valign="top"> <?php echo substr($rmemo,0,100);?></td> <td align="center"><input type="checkbox" name="del[]" id="del" value="<?=$row['timeslip_id']?>"></td> </tr>
  21. Right now I have a search option on my site that searches the database for whatever the user puts in. Well then they can click on a record and they can edit it. What I am trying to accomplish is whenever a user clicks to edit but then decides that was the wrong record they can hit a back button and it will show them their results with what they typed in earlier. If they just click the back button on top they get a "Do you want to resubmit the form". I tried the <a href="#" onclick="history.go(-1);return false;" class="mtn"> Find out that only works on Safari and that isn't good code. Then I tried this... <input type="hidden" name="qry" value="<?=$qry_str?>"> $qry_str is my "SELECT" statement and I am just sending it to my update page as a variable with the POST. On my update page I pull the variable, save it in another one and send it back to the search page if the user clicks the back link. However it keeps adding a '' on both sides of the criteria everytime I send it to a page. For instance, I have: SELECT * FROM tasks WHERE 1 and Owner='cnj'. Then I echo on my update page and its SELECT * FROM tasks WHERE 1 and Owner=''cnj'', then I click the back link and get this: SELECT * FROM tasks WHERE 1 and Owner=''''cnj''''. It is doubling them up everytime. Code on the update page looks like this if you wanted to see <?php $search=$_POST['qry'];?> <FORM name="form1" action="searchtasks.php" method="post"> <input type="hidden" name="return" value="<?=$search?>"></FORM> <a href="javascript: submitform()">Back</a>
  22. When I ran it into sql it brings back all the Indenitifers. I changed the code to this. I hard coded the usernames in there to make sure it was checking against them and now everytime I get that "This is a NEW Client" no matter if I put the correct name or not in there. $existing_users=array('roshan','mike','jason'); //value got from the get metho $user_name=$_REQUEST['course']; //checking weather user exists or not in $existing_users array if (in_array($user_name, $existing_users)) { //user name is not available echo "no"; } else { //username available i.e. user name doesn't exists in array echo "yes"; } ?> $(document).ready(function() { $("#course").blur(function() { //remove all the class add the messagebox classes and start fading $("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow"); //check the username exists or not from ajax $.post("../user_availability.php",{ user_name:$(this).val() } ,function(data) { if(data=='no') //if username not avaiable { $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox { //add message and change the class of the box and start fading $(this).html('Existing Client').addClass('messageboxok').fadeTo(900,1); }); } else { $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox { //add message and change the class of the box and start fading $(this).html('This is a NEW Client').addClass('messageboxerror').fadeTo(900,1); }); } }); }); });
  23. I am trying to make a text field when you go to it and start typing in a clients name it checks the database to see if that name is in there and if it is not tell the user it is a new record. If it is already in there not to say anything. Well here is the code below. I keep getting that it is a new record even when i type specifically a name that is already in the database. Thanks <? //connect to database mysql_connect('localhost', '**', '**'); mysql_select_db('**'); //get the username $course = mysql_real_escape_string($_POST['course']); //mysql query to select field username if it's equal to the username that we check ' $result = mysql_query('select Identifier from timeslip where Identifier = "'. $course .'"'); //if number of rows fields is bigger them 0 that means it's NOT available ' if(mysql_num_rows($result)>0){ //and we send 0 to the ajax request echo 0; }else{ //else if it's not bigger then 0, then it's available ' //and we send 1 to the ajax request echo 1; } ?> $(document).ready(function() { //the min chars for username var min_chars = 3; //result texts var characters_error = 'Minimum amount of chars is 3'; var checking_html = 'Checking...'; //when button is clicked $('#course').keyup(function(){ //run the character number check if($('#course').val().length < min_chars){ //if it's bellow the minimum show characters_error text ' $('#username_availability_result').html(characters_error); }else{ //else show the cheking_text and run the function to check $('#username_availability_result').html(checking_html); check_availability(); } }); }); //function to check username availability function check_availability(){ //get the username var username = $('#course').val(); //use ajax to run the check $.post("../checkid.php", { username: username }, function(result){ //if the result is 1 if(result == 1){ //show that the username is available $('#username_availability_result').html(username + ' is a new record'); } else{ //show that the username is NOT available $('#username_availability_result').html(username + ' is a current record'); } }); } <div id='username_availability_result'></div> Last, First<label></label> <input placeholder="Smith, John" type="text" name="course" id="course" />
  24. I'm not very advanced. While I know how to get around and change code to fit my needs, I'm not very good at writing, unless it's fairly simple. If I wanted to do it the php way, because I was looking at AJAX and I'm not sure if I could write something to do it, where would I start. Would I need it to autorefresh when user clicks on a name and then have it save that name in a variable and then just set the drop down default value as that variable?
  25. I am working on a web app, here's the page I am on : http://sa.uintramural.com/autoselect/timeslip.php The fields choices are being pulled from a database. What I am trying to do is when someone types in a name and selects that person that it would look in the table for the 'Terms' and pull whatever value there is for that person and choose it automatically in the drop down menu. Could you point me in the right direction to do that or show me a code snippet. 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.