Jump to content

ccutla

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Everything posted by ccutla

  1. Well, I did try all of those things, but I still can't get it to send the query through the href. I know that it sends the query through originally, but not through the page number variables or the first, last, next, previous links. Any other suggestions??? Anybody? Thanks again!
  2. I have a search program that includes pagination, I have not been able to figure out where I need to put my search variables into the href's for my results, so now, I get the first page but nothing after that. This is the line that I am pretty sure needs to be included amongst the hrefs: &metode=$metode&search=$search&metode2=$metode2&search2=$search2&metode3=$metode3&search3=$search3 If anyone could explain to me where I need to put that or if I need to do something completely different to pass my search results through the rest of the pages that would be awesome, thanks! php: [code] <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b>DT_STRING</b></td> <td width="100"><b>ACCOUNT</b></td> <td width="30"><b>ACCOUNT_TYPE</b></td> <td width="150"><b>CLIENT_ID</b></td> <td width="150"><b>USER_ID</b></td> </tr> <tr> <td> <?php // Database and Sever Values $user_db = 'root'; // Server Username     $pass_db = 'rootroot'; // Server Password $host_db = 'mysql'; //Server (e.g. localhost) $db = 'AUDITMED'; // Database Name // // Connect Information - No need to edit @mysql_connect ($host_db, $user_db, $pass_db); @mysql_select_db ($db); // $metode = $_REQUEST['metode']; $search = $_REQUEST['search']; $metode2 = $_REQUEST['metode2']; $search2 = $_REQUEST['search2']; $metode3 = $_REQUEST['metode3']; $search3 = $_REQUEST['search3']; $table = 'AUDIT'; // The name of your table in the database $limit = '100'; // How many results should be shown at a time $scroll = '1'; // Do you want the scroll function to be on (1 = YES, 2 = NO) $scrollnumber = '10'; // How many elements to the record bar are shown at a time when the scroll function is on // Get the total number of rows in a database $query1 = mysql_query ("SELECT * FROM $table WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%' ORDER by CLIENT_ID"); $numrows = mysql_num_rows ($query1); // if (!isset ($_GET['show'])) {     $display = 1;      } else {     $display = $_GET['show'];      } // Return results from START to LIMIT $start = (($display * $limit) - $limit); $query2 = mysql_query ("SELECT * FROM $table WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%' ORDER by CLIENT_ID LIMIT $start,$limit"); // Add ORDER BY field ASC or DESC to order the results while ($row = mysql_fetch_array ($query2)) { $variable1=$row["DT_STRING"];         $variable2=$row["ACCOUNT"];         $variable3=$row["ACCOUNT_TYPE"];         $variable4=$row["CLIENT_ID"];         $variable5=$row["USER_ID"];         //table layout for results         echo ("<tr>");         echo ("<td>$variable1</td>");         echo ("<td>$variable2</td>");         echo ("<td>$variable3</td>");         echo ("<td>$variable4</td>");         echo ("<td>$variable5</td>");         echo ("</tr>");          };          // $paging = ceil ($numrows / $limit); // Display the navigation if ($display > 1) {          $previous = $display - 1;      ?> <a href="<?= $_SERVER['PHP_SELF']; ?>?show=1"><< First</a> | <a href="<?= $_SERVER['PHP_SELF'] ?>?show=<?= $previous; ?>">< Previous</a> | <?php } if ($numrows != $limit) {          if ($scroll == 1) {              if ($paging > $scrollnumber) {                          $first = $display;                          $last = ($scrollnumber - 1) + $display;                      }          } else {              $first = 1;                      $last = $paging;                  }          if ($last > $paging ) {                      $first = $paging - ($scrollnumber - 1);                      $last = $paging;                  }          for ($i = $first;$i <= $last;$i++){                  if ($display == $i) {              ?> [ <b><?= $i ?></b> ] <?php                      } else {              ?> [ <a href="<?= $_SERVER['PHP_SELF']; ?>?show=<?= $i; ?>"><?= $i; ?></a> ]              <?php         }     } } if ($display < $paging) {     $next = $display + 1; ?> | <a href="<?= $_SERVER['PHP_SELF']; ?>?show=<?= $next; ?>">Next ></a> | <a href="<?= $_SERVER['PHP_SELF']; ?>?show=<?= $paging; ?>">Last >></a> <?php } // ?> </table> </center> [/code] Thanks again! [b]EDIT BY OBER: PLEASE USE BB CODE TAGS![/b]
  3. I have a search program that uses simple pagination but I want it to show an option to either go next or prev as well as only showing 4 different pages at a time rather than like 100 options. I don't know if it possible to have it be like ---- next> 1 2 3 4... <previous, when I have a lot more than just the 4 pages. I don't know if that makes a whole lot of sense, but any help would be great. php: <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b>DT_STRING</b></td> <td width="100"><b>ACCOUNT</b></td> <td width="30"><b>ACCOUNT_TYPE</b></td> <td width="150"><b>CLIENT_ID</b></td> <td width="150"><b>USER_ID</b></td> </tr> <tr> <td> <?php mysql_connect("mysql","root","rootroot"); mysql_select_db("AUDITMED"); $num = $_GET['num']; if(empty($num)){ $num = 1; }; $limit = 100; $start = ($num-1)*$limit; if ($start == 0){ $start = 1; } $metode = $_REQUEST['metode']; $search = $_REQUEST['search']; $metode2 = $_REQUEST['metode2']; $search2 = $_REQUEST['search2']; $metode3 = $_REQUEST['metode3']; $search3 = $_REQUEST['search3']; $query = "SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%' ORDER by CLIENT_ID LIMIT $start, $limit"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results echo ("<tr>"); echo ("<td>$variable1</td>"); echo ("<td>$variable2</td>"); echo ("<td>$variable3</td>"); echo ("<td>$variable4</td>"); echo ("<td>$variable5</td>"); echo ("</tr>"); }; $totalpages = mysql_num_rows(mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%'")); $totalpages = $totalpages / $limit; if ($totalpages == round($totalpages,0)) { $totalpages = round($totalpages,0) ; }else { $totalpages = round($totalpages,0) + 1; } $c = 0; echo "<br>"; while($c<$totalpages){ $page = ++$c; if($_GET['num']==$page){ echo "[$page] "; }else{//else echo "<a href=?num=$page&metode=$metode&search=$search&metode2=$metode2&search2=$search2&metode3=$metode3&search3=$search3>[$page] </a>"; } } echo "<br>".$totalpages." Pages in total."; ?> </table> </center>
  4. I have not done that, but I am kind of new to this so I can't seem to get it to work properly when I add the variables into the url string this is the way I'm trying to do it, but it definitely isn't working right. while($c<$totalpages){ $page = ++$c; if($_GET['num']==$page){ echo "[$page] "; }else{//else echo "<a href=?num=$page&[ $metode = $_REQUEST['metode']; $search = $_REQUEST['search']; $metode2 = $_REQUEST['metode2']; $search2 = $_REQUEST['search2']; $metode3 = $_REQUEST['metode3']; $search3 = $_REQUEST['search3']; >[$page] </a>"; } } echo "<br>".$totalpages." Pages in total.";
  5. I am having trouble with the paging of my search results, the first page of results shows up fine, and it shows the proper number of pages, but if I click on page 2 or more, it says that I have 0 pages of results. This is the script I have that runs the results of my search. PHP: <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b>DT_STRING</b></td> <td width="100"><b>ACCOUNT</b></td> <td width="30"><b>ACCOUNT_TYPE</b></td> <td width="150"><b>CLIENT_ID</b></td> <td width="150"><b>USER_ID</b></td> </tr> <tr> <td> <?php mysql_connect("mysql","root","rootroot"); mysql_select_db("AUDITMED"); $num = $_GET['num']; if(empty($num)){ $num = 1; }; $limit = 100; $start = ($num-1)*$limit; if ($start == 0){ $start = 1; } $metode = $_REQUEST['metode']; $search = $_REQUEST['search']; $metode2 = $_REQUEST['metode2']; $search2 = $_REQUEST['search2']; $metode3 = $_REQUEST['metode3']; $search3 = $_REQUEST['search3']; $query = "SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%' ORDER by CLIENT_ID LIMIT $start, $limit"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results echo ("<tr>"); echo ("<td>$variable1</td>"); echo ("<td>$variable2</td>"); echo ("<td>$variable3</td>"); echo ("<td>$variable4</td>"); echo ("<td>$variable5</td>"); echo ("</tr>"); }; $totalpages = mysql_num_rows(mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%'")); $totalpages = $totalpages / $limit; if ($totalpages == round($totalpages,0)) { $totalpages = round($totalpages,0) ; }else { $totalpages = round($totalpages,0) + 1; } $c = 0; echo "<br>"; while($c<$totalpages){ $page = ++$c; if($_GET['num']==$page){ echo "[$page] "; }else{//else echo "<a href=?num=$page>[$page] </a>"; } } echo "<br>".$totalpages." Pages in total."; ?> </table> </center> What in the world am I missing?
  6. ccutla

    HELP!!!!

    Alright, that is very true, I changed that so that it would connect and echoed it out to make sure it was connecting, but I still get no results back, let alone the basic table headers that I know works on other scripts. Any other suggestions??
  7. I am very new to this whole programming biz so bare with me if I am missing something very obvious. I have gone to and tried just about all of the tutorials I could find on php mysql pagination. I cannot seem to get it all together at once. Here is what I have for just a general query of my DB all I want to do is to get a simple paging system in place.... php: <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b>DT_STRING</b></td> <td width="100"><b>ACCOUNT</b></td> <td width="30"><b>ACCOUNT_TYPE</b></td> <td width="150"><b>CLIENT_ID</b></td> <td width="150"><b>USER_ID</b></td> </tr> <tr> <td> <?php // Database Connection mysql_connect(mysql, root, rootroot) or die("ERROR--CAN'T CONNECT TO SERVER"); mysql_select_db("AUDITMED") or die("ERROR--CAN'T CONNECT TO DB"); $rowsPerPage = 20; $pageNum = 1; if(isset($_GET['page'])) { $pageNum = $_GET['page']; } $offset = ($pageNum - 1) * $rowsPerPage; $query = "SELECT * FROM AUDIT LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query failed'); while(list($val) = mysql_fetch_array($result)) { $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results echo ("<tr>"); echo ("<td>$variable1</td>"); echo ("<td>$variable2</td>"); echo ("<td>$variable3</td>"); echo ("<td>$variable4</td>"); echo ("<td>$variable5</td>"); echo ("</tr>"); } echo '<br>'; $query = "SELECT COUNT(val) AS numrows FROM AUDIT"; $result = mysql_query($query) or die('Error, query failed'); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; $maxPage = ceil($numrows/$rowsPerPage); $self = $_SERVER['PHP_SELF']; if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page\">[Prev]</a> "; $first = " <a href=\"$self?page=1\">[First Page]</a> "; } else { $prev = ' [Prev] '; $first = ' [First Page] '; } if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page\">[Next]</a> "; $last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> "; } else { $next = ' [Next] '; $last = ' [Last Page] '; } $pagelinks = ''; for(i=1; i<maxPage; i++){ $pagelinks .= " <a href=\"$self?page=$i\">[$i]</a> "; } // print the page navigation link echo $first . $prev . $pagelinks . $next . $last; ?> </table> </center> I get no results, period, not even the table will show up when I try to run this script, but as far as the tutorials that I've read it should work. I know there is something quite obvious that I'm missing, any suggestions would be greatly appreciated. Thanks a lot! Boof Boof Duff Duff
  8. I am in need of a little bit of help. I have a PHP MYSQL search program in place that I just finally figured out how to return a limited number of results with the option of going to however many pages of results there are for each query. My problem is that I can only view the results from the first page. I can go to the "next" page, but it doesn't return anymore of the actual records, just the table heading. Any suggestions would be greatly appreciated. Here is my search script, PHP: <html> <body> <h1><center>Audit Database Search</center></h1> <br><br><br><br> <form method="post" action="http://mysql/phppages/pppppp.php" target="_blank"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td bordercolor="#000000"> <p align="center"> <select name="metode" size="1"> <option value="DT_STRING">Date</option> <option value="ACCOUNT">Account</option> <option value="ACCOUNT_TYPE">Account Type</option> <option value="CLIENT_ID">Client ID</option> <option value="USER_ID">User ID</option> </select> <input type="text" name="search" size="25"> &nbsp;<br> </td> </tr> </table> </div> <br> <form method="post" action="http://mysql/phppages/pppppp.php" target="_blank"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td bordercolor="#000000"><div> <p align="center"> <select name="metode2" size="1"> <option value="DT_STRING">Date</option> <option value="ACCOUNT">Account</option> <option value="ACCOUNT_TYPE">Account Type</option> <option value="CLIENT_ID">Client ID</option> <option value="USER_ID">User ID</option> </select> <input type="text" name="search2" size="25"> &nbsp;<br> Search database: <input type="submit" value="Go!!" name="Go"></p> </form> </body> </html> and here is the results page that I am having the troubles with PHP: <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b>DT_STRING</b></td> <td width="100"><b>ACCOUNT</b></td> <td width="30"><b>ACCOUNT_TYPE</b></td> <td width="150"><b>CLIENT_ID</b></td> <td width="150"><b>USER_ID</b></td> </tr> <tr> <td> <?php // Database Connection mysql_connect(mysql, root, rootroot) or die("ERROR--CAN'T CONNECT TO SERVER"); mysql_select_db("AUDITMED") or die("ERROR--CAN'T CONNECT TO DB"); // If current page number, use it // if not, set one! if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } // Define the number of results per page $max_results = 30; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); // Perform MySQL query on only the current page number's results $metode = $_REQUEST['metode']; $search = $_REQUEST['search']; $metode2 = $_REQUEST['metode2']; $search2 = $_REQUEST['search2']; $sql = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' LIMIT $from, $max_results"); //while($row = mysql_fetch_array($sql)){ // Build your formatted results here. if(mysql_num_rows($sql) >= 1) { while ($row = mysql_fetch_array($sql)){ { $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results echo ("<tr>"); echo ("<td>$variable1</td>"); echo ("<td>$variable2</td>"); echo ("<td>$variable3</td>"); echo ("<td>$variable4</td>"); echo ("<td>$variable5</td>"); echo ("</tr>"); } } } else { "Your search criterea returned no results"; } // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%'"),0); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); // Build Page Number Hyperlinks echo "<center>Select a Page<br />"; // Build Previous Link if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } // Build Next Link if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; } echo "</center>"; ?> </table> </center> Thanks again!
  9. I am trying to get help with this pagination program, I don't know what to do about getting an error message stating: "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 '0, 25' at line 2". I don't see the problem with my script. Any ideas? php: <?php @mysql_connect(mysql, , ) or die("ERROR--CAN'T CONNECT TO SERVER"); @mysql_select_db(AUDITMED) or die("ERROR--CAN'T CONNECT TO DB"); $metode = $_REQUEST['metode']; $search = $_REQUEST['search']; $metode2 = $_REQUEST['metode2']; $search2 = $_REQUEST['search2']; $limit = 25; $query_count = "SELECT count(*) FROM AUDIT"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT `AUDIT` . `DT_STRING` , `AUDIT` . `ACCOUNT` , `AUDIT` . `ACCOUNT_TYPE` , `AUDIT` . `CLIENT_ID` , `AUDIT` . `USER_ID` FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' ORDER BY DT_STRING $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } $bgcolor = "#E0E0E0"; // light gray echo("<table>"); while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor.">n<td>"); echo($row["'DT_STRING','ACCOUNT','ACCOUNT_TYPE','CLIENT_ID','USER_ID'"]); echo("</td>n<td>"); echo($row["'DT_STRING','ACCOUNT','ACCOUNT_TYPE','CLIENT_ID','USER_ID'"]); echo("</td>n</tr>"); } echo("</table>"); if($page != 1){ $pageprev = $page--; echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> "); }else{ echo("PREV".$limit." "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>"); }else{ echo("NEXT".$limit); } mysql_free_result($result); ?> Thanks for any help in advance!
  10. Well, I have tried about everything and I still get an error message saying: "Unable to perform query: 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 'LIKE '%$search%' AND LIKE '%$search2%' ORDER BY 'DT_STRING' ASC' at line 1" It doesn't make sense to me, because I changed it so that it would search through including search and search2 in the column headers. Anybody else have any ideas? Here is what my script looks like at this point: php: <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b><a href="?search=$search&search2=$search2&sortby=DT_STRING">DT_STRING</a></b></td> <td width="100"><b><a href="?search=$search&search2=$search2&sortby=ACCOUNT">ACCOUNT</a></b></td> <td width="30"><b><a href="?search=$search&search2=$search2&sortby=ACCOUNT_TYPE">ACCOUNT_TYPE</a></b></td> <td width="150"><b><a href="?search=$search&search2=$search2&sortby=CLIENT_ID">CLIENT_ID</a></b></td> <td width="150"><b><a href="?search=$search&search2=$search2&sortby=USER_ID">USER_ID</a></b></td> </tr> <tr> <td> <? $hostname = "mysql"; // The Thinkhost DB server. $username = ""; // The username you created for this database. $password = ""; // The password you created for the username. $usertable = "AUDIT"; // The name of the table you made. $dbName = "AUDITMED"; // This is the name of the database you made. MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable"); @mysql_select_db( "$dbName") or die( "Unable to select database"); //error message (not found message)begins $XX = "No Record Found, to search again please close this window"; //query details table begins $metode = $_REQUEST['metode']; $search = $_REQUEST['search']; $metode2 = $_REQUEST['metode2']; $search2 = $_REQUEST['search2']; $sortvalues = array("DT_STRING", "ACCOUNT", "ACCOUNT_TYPE", "CLIENT_ID", "USER_ID"); if(isset($_GET['sortby']) && in_array($_GET['sortby'], $sortvalues)) { $sortby = $_GET['sortby']; } else { $sortby = "DT_STRING"; } $query = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%{$search}%' AND $metode2 LIKE '%{$search2}%' ORDER BY '$sortby' ASC") or die("Unable to perform query: " . mysql_error()); if(mysql_num_rows($query) >= 1) { while ($row = mysql_fetch_array($query)) { $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results print ("<tr>"); print ("<td>$variable1</td>"); print ("<td>$variable2</td>"); print ("<td>$variable3</td>"); print ("<td>$variable4</td>"); print ("<td>$variable5</td>"); print ("</tr>"); } } else { "Your search criterea returned no results"; } //end ?> </table> </center> Thanks again for any ideas!
  11. Thanks for trying, I am still getting the exact same message when I do that so I don't know what the deal is. If you have any other suggestions, I am willing to try anything at this point. Thanks again!
  12. I did that but now when I click on a table heading it gives me this error: "Unable to perform query: 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 'LIKE '%%' AND LIKE '%%' ORDER BY DT_STRING ASC' at line 1" I don't know exactly what that means but if anybody does I could really use the help. Thanks again!
  13. I have this script to hopefully sort by the headers in my results table, but when I click on the headers it goes to the error page that says there is no data to display. Any ideas? Thanks a lot! php: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b><a href="?sortby=DT_STRING">DT_STRING</a></b></td> <td width="100"><b><a href="?sortby=ACCOUNT">ACCOUNT</a></b></td> <td width="30"><b><a href="?sortby=ACCOUNT_TYPE">ACCOUNT_TYPE</a></b></td> <td width="150"><b><a href="?sortby=CLIENT_ID">CLIENT_ID</a></b></td> <td width="150"><b><a href="?sortby=USER_ID">USER_ID</a></b></td> </tr> <tr> <td> <? $hostname = "mysql"; // The Thinkhost DB server. $username = ""; // The username you created for this database. $password = ""; // The password you created for the username. $usertable = "AUDIT"; // The name of the table you made. $dbName = "AUDITMED"; // This is the name of the database you made. MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable"); @mysql_select_db( "$dbName") or die( "Unable to select database"); //error message (not found message)begins $XX = "No Record Found, to search again please close this window"; $metode = $_POST['metode']; $search = $_POST['search']; $metode2 = $_POST['metode2']; $search2 = $_POST['search2']; $sortvalues = array("DT_STRING", "ACCOUNT", "ACCOUNT_TYPE", "CLIENT_ID", "USER_ID"); if(isset($_GET['sortby']) && in_array($_GET['sortby'], $sortvalues)) { $sortby = $_GET['sortby']; } else { $sortby = "DT_STRING"; } $query = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' ORDER BY $sortby ASC"); while ($row = @mysql_fetch_array($query)) { $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results print ("<tr>"); print ("<td>$variable1</td>"); print ("<td>$variable2</td>"); print ("<td>$variable3</td>"); print ("<td>$variable4</td>"); print ("<td>$variable5</td>"); print ("</tr>"); } //below this is the function for no record!! if (!$variable1) { print ("$XX"); } //end ?> </table> </center> Thanks again for any advice!
  14. Thanks for the reply! I put in the new code and it does try to sort when I click on the headers, but it does not return any results it shows up as the no records found error. The original search still works, but not the sort. I don't know if you have any idea of why that is, I am trying to see if the values for the $sortby are all correct. Any further suggestions would be appreciated greatly! Thanks again!
  15. I am trying to be able to sort a table by the different column headings. The table is the result of a search of a mysql db and I have no idea how or where to start. Any suggestions??? Thanks a lot! This is the results page of my search where I need the sort to happen: php: <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b>DT_STRING</b></td> <td width="100"><b>ACCOUNT</b></td> <td width="30"><b>ACCOUNT_TYPE</b></td> <td width="150"><b>CLIENT_ID</b></td> <td width="150"><b>USER_ID</b></td> </tr> <tr> <td> <? $hostname = "mysql"; // The Thinkhost DB server. $username = ""; // The username you created for this database. $password = ""; // The password you created for the username. $usertable = "AUDIT"; // The name of the table you made. $dbName = "AUDITMED"; // This is the name of the database you made. MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable"); @mysql_select_db( "$dbName") or die( "Unable to select database"); //error message (not found message)begins $XX = "No Record Found, to search again please close this window"; //query details table begins $metode = $_POST['metode']; $search = $_POST['search']; $metode2 = $_POST['metode2']; $search2 = $_POST['search2']; $query = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%'"); while ($row = @mysql_fetch_array($query)) { $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results print ("<tr>"); print ("<td>$variable1</td>"); print ("<td>$variable2</td>"); print ("<td>$variable3</td>"); print ("<td>$variable4</td>"); print ("<td>$variable5</td>"); print ("</tr>"); } //below this is the function for no record!! if (!$variable1) { print ("$XX"); } //end ?> </table> </center> Thanks again!
  16. I am trying to be able to sort a table by the different column headings. The table is the result of a search of a mysql db and I have no idea how or where to start. Any suggestions??? Thanks a lot! This is the results page of my search where I need the sort to happen: php: <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b>DT_STRING</b></td> <td width="100"><b>ACCOUNT</b></td> <td width="30"><b>ACCOUNT_TYPE</b></td> <td width="150"><b>CLIENT_ID</b></td> <td width="150"><b>USER_ID</b></td> </tr> <tr> <td> <? $hostname = "mysql"; // The Thinkhost DB server. $username = "root"; // The username you created for this database. $password = "rootroot"; // The password you created for the username. $usertable = "AUDIT"; // The name of the table you made. $dbName = "AUDITMED"; // This is the name of the database you made. MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable"); @mysql_select_db( "$dbName") or die( "Unable to select database"); //error message (not found message)begins $XX = "No Record Found, to search again please close this window"; //query details table begins $metode = $_POST['metode']; $search = $_POST['search']; $metode2 = $_POST['metode2']; $search2 = $_POST['search2']; $query = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%'"); while ($row = @mysql_fetch_array($query)) { $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results print ("<tr>"); print ("<td>$variable1</td>"); print ("<td>$variable2</td>"); print ("<td>$variable3</td>"); print ("<td>$variable4</td>"); print ("<td>$variable5</td>"); print ("</tr>"); } //below this is the function for no record!! if (!$variable1) { print ("$XX"); } //end ?> </table> </center> Thanks again!
  17. Well that was a good thought, but it didn't seem to work. Any other suggestions?? I don't know if my variables are wrong or what the deal is. Thanks anyways.
  18. I am trying to use this first html page using two different drop-down boxes to search a database and display the results, I can get it to work using a single drop-down, but when I try to use two seperate ones it doesn't return any results. Any help would be greatly appreciated, Thanks! search.html: <html> <body> <h1><center>Audit Database Search</center></h1> <br><br><br><br> <form method="post" action="http://mysql/phppages/results.php" target="_blank"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td bordercolor="#000000"> <p align="center"> <select name="metode" size="1"> <option value="DT_STRING">Date</option> <option value="ACCOUNT">Account</option> <option value="ACCOUNT_TYPE">Account Type</option> <option value="CLIENT_ID">Client ID</option> <option value="USER_ID">User ID</option> </select> <input type="text" name="search" size="25"> &nbsp;<br> </td> </tr> </table> </div> <form method="post" action="http://mysql/phppages/results.php" target="_blank"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td bordercolor="#000000"> <p align="center"> <select name="metode2" size="1"> <option value="DT_STRING">Date</option> <option value="ACCOUNT">Account</option> <option value="ACCOUNT_TYPE">Account Type</option> <option value="CLIENT_ID">Client ID</option> <option value="USER_ID">User ID</option> </select> <input type="text" name="search2" size="25"> &nbsp;<br> Search database: <input type="submit" value="Go!!" name="Go"></p> </td> </tr> </table> </div> </form> </form> </body> </html> results.php: <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b>DT_STRING</b></td> <td width="100"><b>ACCOUNT</b></td> <td width="30"><b>ACCOUNT_TYPE</b></td> <td width="150"><b>CLIENT_ID</b></td> <td width="150"><b>USER_ID</b></td> </tr> <tr> <td> <? $hostname = "mysql"; // The Thinkhost DB server. $username = ""; // The username you created for this database. $password = ""; // The password you created for the username. $usertable = "AUDIT"; // The name of the table you made. $dbName = "AUDITMED"; // This is the name of the database you made. MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable"); @mysql_select_db( "$dbName") or die( "Unable to select database"); //error message (not found message)begins $XX = "No Record Found, to search again please close this window"; //query details table begins $metode2 = $_POST['metode2']; $metode = $_POST['metode']; $search = $_POST['search']; $search2 = $_POST['search2']; $query = mysql_query("SELECT * FROM $usertable WHERE "$metode AND $metode2" = "'%$search%' AND '%$search2%'""); while ($row = @mysql_fetch_array($query)) { $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results print ("<tr>"); print ("<td>$variable1</td>"); print ("<td>$variable2</td>"); print ("<td>$variable3</td>"); print ("<td>$variable4</td>"); print ("<td>$variable5</td>"); print ("</tr>"); } //below this is the function for no record!! if (!$variable1) { print ("$XX"); } //end ?> </table> </center> Grrr! I am out of ideas!
  19. This is my first post, I am just looking for a little help. I have a script that successfully searches a sql server one query at a time, but I want to be able to search by more than one column of the database and return a report. This is what I have so far as my search and results pages go... php: (search.html) <html> <body> <h1><center>Audit Database Search</center></h1> <br><br><br><br> <form method="post" action="http://mysql/phppages/results.php" target="_blank"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td bordercolor="#000000"> <p align="center"> <select name="metode" size="1"> <option value="DT_STRING">Date</option> <option value="ACCOUNT">Account</option> <option value="ACCOUNT_TYPE">Account Type</option> <option value="CLIENT_ID">Client ID</option> <option value="USER_ID">User ID</option> </select> <input type="text" name="search" size="25"> &nbsp;<br> Search database: <input type="submit" value="Go!!" name="Go"></p> </td> </tr> </table> </div> </form> </body> </html> Which then returns the results using this page (results.php): php: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="60"><b>DT_STRING</b></td> <td width="100"><b>ACCOUNT</b></td> <td width="30"><b>ACCOUNT_TYPE</b></td> <td width="150"><b>CLIENT_ID</b></td> <td width="150"><b>USER_ID</b></td> </tr> <tr> <td> <? $hostname = "mysql"; $username = ""; $password = ""; $usertable = ""; $dbName = ""; MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable"); @mysql_select_db( "$dbName") or die( "Unable to select database"); //error message (not found message)begins $XX = "No Record Found, to search again please close this window"; //query details table begins $metode = $_POST['metode']; $search = $_POST['search']; $query = mysql_query("SELECT * FROM $usertable WHERE $metode LIKE '%$search%'"); while ($row = @mysql_fetch_array($query)) { $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results print ("<tr>"); print ("<td>$variable1</td>"); print ("<td>$variable2</td>"); print ("<td>$variable3</td>"); print ("<td>$variable4</td>"); print ("<td>$variable5</td>"); print ("</tr>"); } if (!$variable1) { print ("$XX } //end ?> </table> </center> Any tips or suggestions would be greatly appreciated, 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.