Jump to content

emilcarlo

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by emilcarlo

  1. Hello nethnet, The fixes you did worked ^^ The pagination and the search function is good now, but a new problem surfaced xD I am trying to understand and see where the problem is just like you guys. Anyway, here's the problem. I have couple of data now in my database, but the pages do not go beyond 2nd page xD. The
  2. Hi nethnet, Sorry for the late response. Thank you for helping out with the code I am yet to try the fixes you made with my code ^^ I really appreciate the help, thank you!
  3. Hello nethnet, Thank you very much for your response. Honestly, I barely understood what you just said because I am just like about three weeks in doing php, and is still trying to learn the basics, but due to the project's need, I need to move a little advanced with the tutorials and pre-made codes available in web. If you won't mind at all, can you clarify on the things I need to do?
  4. So basically, what happens here now is that the search query and the pagination now somehow works with each other. Each time I search for a key word, it displays the information perfectly, with pagination. However, even if the keyword I looked for has only 2 information, a second page is available for click, and when I try to click, it leads me to a page of blank information. Similarly, if I search for an information that should display huge amount of data, it displays pagination, but displays no information if I click on the second page. What could the reason be behind this? Immediate response is very much appreciated. Thanks! <link href="add_client.css" rel="stylesheet" type="text/css"> <?PHP include("dbconnection.php"); //database connection $query = "SELECT * FROM records"; ?> <!-- Start of table --> <table width="760" border="0" align="center" cellpadding="0" cellspacing="0"> <td> <table width="760" border="0" cellpadding="0" cellspacing="0"> <!-- Table data containing the Logo --> <td width="199" align="center" valign="top"> <a href="login.html"> <img src="asia.gif" alt="" width="152" height="58" border="0" /> </a> </td> <!-- Table data containing Home button --> <td width="176" align="right" valign="bottom"> <a href="main.php"> <img src="Home.jpg" width="104" height="20" border="0"/> </a> </td> <!-- Table data containing View Client button --> <td width="130" align="right" valign="bottom"> <img src="View.jpg" width="104" height="20" border="0"/> </td> <!-- Table data containing the Add Client button --> <td width="146" align="right" valign="bottom"> <a href="add_client.php"> <img src="Add.jpg" width="104" height="20" border="0"/> </a> </td> <!-- Blank table data --> <td width="109" align="right" valign="bottom"> </td> </table> <!-- Table design division and body--> <table width="760" border="0" cellpadding="0" cellspacing="0"> <td width="200" height="3" bgcolor="#1B1C78"> <img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td> <td width="560" bgcolor="#0076CC"> <img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td> <tr> <td height="500" colspan="2" align="center" valign="top" bgcolor="#F3FAFE"> <!-- Page contents --> <!-- Search Query --> <br> <form name="form" action="view_client.php" method="post"> <table width="351" border="0"> <tr> <td width="137" align="left" valign="middle"> SEARCH RECORD: </td> <td width="144" align="center" valign="middle"> <input type="text" name="search" /> </td> <td width="56" align="left" valign="middle"> <input type="submit" name="btnSearch" value="Search" /> </td> </tr> </table> <br> <!-- End of search query--> <!-- Start of Search Results--> <table border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" > <tr> <th width="80" align="center" bgcolor="#E0E8F3">Territory</th> <th width="330" align="center" bgcolor="#E0E8F3">Employer</th> <th width="160" align="center" bgcolor="#E0E8F3">Name</th> <th width="80" align="center" valign="middle" bgcolor="#E0E8F3"> </th> </tr> <?php //max displayed per page $per_page = 15; //get start variable $start = $_GET['start']; //count records $record_count = mysql_num_rows(mysql_query("SELECT * FROM records")); //count max pages $max_pages = $record_count / $per_page; //may come out as decimal if (!$start) $start = 0; //display data via search query if(isset($_POST["btnSearch"])) { $get = mysql_query("SELECT * FROM records WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' ORDER BY territory ASC LIMIT $start, $per_page"); while ($row = mysql_fetch_assoc($get)) // get data { $id = trim($row['id']); $territory = trim($row['territory']); $employer = trim($row['employer']); $last_name = trim($row['last_name']); $first_name = trim($row['first_name']); echo "<td>".$territory."</td>"; echo "<td>".$employer."</td>"; echo "<td>".$last_name.", ".$first_name."</td>"; echo "<td><a href='edit_client.php?id=".$id."'>edit</a> | <a href='delete_client.php?id=".$id."'>delete</a></td>"; echo "<tr>"; } //setup prev and next variables $prev = $start - $per_page; $next = $start + $per_page; //show prev button if (!($start<=0)) echo "<a href='view_client.php?start=$prev'>Prev</a> "; //show page numbers //set variable for first page $i=1; for ($x=0;$x<$record_count;$x=$x+$per_page) { if ($start!=$x) echo " <a href='view_client.php?start=$x'>$i</a> "; else echo " <a href='view_client.php?start=$x'><b>$i</b></a> "; $i++; } //show next button if (!($start>=$record_count-$per_page)) echo " <a href='view_client.php?start=$next'>Next</a>"; } ?> </table> </form> <!-- End of page --> </td> </tr> </table> </td> <tr> <td height="38"> <table width="760" border="0" cellpadding="0" cellspacing="0"> <td width="200" height="35" align="center" bgcolor="#1B1C78" class=white> <a href="disclaimer.html"> <font color="#FFFFFF">Legal Disclaimer</font> </a> </td> <td width="560" align="center" bgcolor="#0076CC"> Copyright © 2006 - 2010 Limited. All rights reserved. </td> </table></td> </tr> </table>
  5. Good Evening, What I am trying to do in here is to display data based on my selected option in the drop down list. I don't have submit button, I just want it to automatically display results based on my selection. Here's my code: <link href="add_client.css" rel="stylesheet" type="text/css"> <?PHP include("dbconnection.php"); //Include database connection to file $query = "SELECT * FROM records"; if(isset($_POST["territory"])) { $query .= " WHERE territory LIKE '%".$_POST["territory"]."%' ORDER BY territory ASC LIMIT 0,15" ; $result = mysql_query($query, $connection) or die(mysql_error()); } ?> <!-- Start of table --> <table width="760" border="0" align="center" cellpadding="0" cellspacing="0"> <td> <table width="760" border="0" cellpadding="0" cellspacing="0"> <!-- Table data containing the Asia Logo --> <td width="199" align="center" valign="top"> <a href="login.html"> <img src="asia.gif" alt="" width="152" height="58" border="0" /> </a> </td> <!-- Table data containing Home button --> <td width="176" align="right" valign="bottom"> <a href="main.php"> <img src="Home.jpg" width="104" height="20" border="0"/> </a> </td> <!-- Table data containing View Client button --> <td width="130" align="right" valign="bottom"> <img src="View.jpg" width="104" height="20" border="0"/> </td> <!-- Table data containing the Add Client button --> <td width="146" align="right" valign="bottom"> <a href="add_client.php"> <img src="Add.jpg" width="104" height="20" border="0"/> </a> </td> <!-- Blank table data --> <td width="109" align="right" valign="bottom"> </td> </table> <!-- Table design division and body--> <table width="760" border="0" cellpadding="0" cellspacing="0"> <td width="200" height="3" bgcolor="#1B1C78"> <img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td> <td width="560" bgcolor="#0076CC"> <img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td> <tr> <td height="500" colspan="2" align="center" valign="top" bgcolor="#F3FAFE"> <!-- Page contents --> <!-- Search Query --> <br> <form name="form" action="trustlist.php" method="post"> <table width="293" border="0"> <tr> <td width="140" align="left" valign="middle"> SEARCH RECORD: </td> <td width="143" align="center" valign="middle"><select name="territory" id="territory" style="width: 143px" width="230"> <option selected="selected" disabled="disabled">Select Territory</option> <option>Territory 01</option> <option>Territory 02</option> <option>Territory 03</option> <option>Territory 04</option> <option>Territory 05</option> <option>Territory 06</option> <option>Territory 07</option> <option>Territory 08</option> <option>Territory 09</option> <option>Territory 10</option> </select></td> </tr> </table> <br> <!-- End of search query--> <!-- Start of Search Results--> <table border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" > <tr> <th width="148" align="center" bgcolor="#E0E8F3">Acute Trusts</th> <th width="262" align="center" bgcolor="#E0E8F3">Employer</th> <th width="160" align="center" bgcolor="#E0E8F3">Name</th> <th width="80" align="center" valign="middle" bgcolor="#E0E8F3"> </th> </tr> <?php if($result) { for($i=0; $i<mysql_num_rows($result); $i++) { $id = trim(mysql_result($result, $i, "id")); $territory = trim(mysql_result($result, $i, "territory")); $employer = trim(mysql_result($result, $i, "employer")); $first_name = trim(mysql_result($result, $i, "first_name")); $last_name = trim(mysql_result($result, $i, "last_name")); echo "<tr>"; echo "<td>".$territory."</td>"; echo "<td>".$employer."</td>"; echo "<td>".$last_name.", ".$first_name."</td>"; echo "<td><a href='edit_client.php?id=".$id."'>edit</a> | <a href='delete_client.php?id=".$id."'>delete</a></td>"; echo "</tr>"; } } ?> </table> </form> <!-- End of page --> </td> </tr> </table> </td> <tr> <td height="38"> <table width="760" border="0" cellpadding="0" cellspacing="0"> <td width="200" height="35" align="center" bgcolor="#1B1C78" class=white> <a href="disclaimer.html"> <font color="#FFFFFF">Legal Disclaimer</font> </a> </td> <td width="560" align="center" bgcolor="#0076CC"> Copyright © 2006 - 2010 AsiaLimited. All rights reserved. </td> </table></td> </tr> </table>
  6. Good Evening, I've been in a trial and error state for the past week trying to figure out how I can put on the pre-made pagination scripts I found on the web, but of no luck. I have just started programming like two weeks ago, and is still trying to understand logics and stuffs so I can get my desired output. So far, everything is doing well except for one - I am really having a hard time to incorporate pagination scripts with my code. To rank myself as a php programmer, I can say I am lower than one, and seemingly, what I want to achieve is an advanced code. Can anyone help me on what pagination code I should try to play with and incorporate with my code? Here's my code so far: <?PHP include("dbconnection.php"); //Include database connection to file $query = "SELECT * FROM records"; if(isset($_POST["btnSearch"])) { $query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' ORDER BY territory ASC LIMIT 0,15" ; $result = mysql_query($query, $connection) or die(mysql_error()); } ?> <!-- Start of table --> <table width="760" border="0" align="center" cellpadding="0" cellspacing="0"> <td> <table width="760" border="0" cellpadding="0" cellspacing="0"> <!-- Table data containing the Asia Logo --> <td width="199" align="center" valign="top"> <a href="login.html"> <img src="asia.gif" alt="" width="152" height="58" border="0" /> </a> </td> <!-- Table data containing Home button --> <td width="176" align="right" valign="bottom"> <a href="main.php"> <img src="Home.jpg" width="104" height="20" border="0"/> </a> </td> <!-- Table data containing View Client button --> <td width="130" align="right" valign="bottom"> <img src="View.jpg" width="104" height="20" border="0"/> </td> <!-- Table data containing the Add Client button --> <td width="146" align="right" valign="bottom"> <a href="add_client.php"> <img src="Add.jpg" width="104" height="20" border="0"/> </a> </td> <!-- Blank table data --> <td width="109" align="right" valign="bottom"> </td> </table> <!-- Table design division and body--> <table width="760" border="0" cellpadding="0" cellspacing="0"> <td width="200" height="3" bgcolor="#1B1C78"> <img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td> <td width="560" bgcolor="#0076CC"> <img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td> <tr> <td height="500" colspan="2" align="center" valign="top" bgcolor="#F3FAFE"> <!-- Page contents --> <!-- Search Query --> <br> <form name="form" action="view_client.php" method="post"> <table width="351" border="0"> <tr> <td width="137" align="left" valign="middle"> SEARCH RECORD: </td> <td width="144" align="center" valign="middle"> <input type="text" name="search" /> </td> <td width="56" align="left" valign="middle"> <input type="submit" name="btnSearch" value="Search" /> </td> </tr> </table> <br> <!-- End of search query--> <!-- Start of Search Results--> <table border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" > <tr> <th width="80" align="center" bgcolor="#E0E8F3">Territory</th> <th width="330" align="center" bgcolor="#E0E8F3">Employer</th> <th width="160" align="center" bgcolor="#E0E8F3">Name</th> <th width="80" align="center" valign="middle" bgcolor="#E0E8F3"> </th> </tr> <?php if($result) { for($i=0; $i<mysql_num_rows($result); $i++) { $id = trim(mysql_result($result, $i, "id")); $territory = trim(mysql_result($result, $i, "territory")); $employer = trim(mysql_result($result, $i, "employer")); $first_name = trim(mysql_result($result, $i, "first_name")); $last_name = trim(mysql_result($result, $i, "last_name")); echo "<tr>"; echo "<td>".$territory."</td>"; echo "<td>".$employer."</td>"; echo "<td>".$last_name.", ".$first_name."</td>"; echo "<td><a href='edit_client.php?id=".$id."'>edit</a> | <a href='delete_client.php?id=".$id."'>delete</a></td>"; echo "</tr>"; } } ?> </table> </form> <!-- End of page --> </td> </tr> </table> </td> <tr> <td height="38"> <table width="760" border="0" cellpadding="0" cellspacing="0"> <td width="200" height="35" align="center" bgcolor="#1B1C78" class=white> <a href="disclaimer.html"> <font color="#FFFFFF">Legal Disclaimer</font> </a> </td> <td width="560" align="center" bgcolor="#0076CC"> Copyright © 2006 - 2010 Asia. All rights reserved. </td> </table></td> </tr> </table> Thank you very much, and I am looking forward for your responses. Thanks!
  7. DELETE FROM tablename WHERE userID='2567' || usgID='2567'
  8. Good evening, I am a newbie when it comes to programming, and I am yet learning. With several help from this forum, and other websites, I am able to finish my very first PHP project. It worked fine, as well as the search engine. However, it is foreseen that the application will be utilizing huge amount of data which would require pagination when viewing. And so I found a tutorial from php freaks as well. However, after I integrated the codes from my web application, the search engine suddenly stopped working. It is still, when I leave the field blank, which would display all data. However, if I type down a search query on the field, it still displays all data. Can anyone help me on this? Here's my complete code: <link href="add_client.css" rel="stylesheet" type="text/css"> <?PHP include("dbconnection.php"); $query = "SELECT * FROM records"; if(isset($_POST["btnSearch"])) { $query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' ORDER BY territory ASC" ; $result = mysql_query($query, $connection) or die(mysql_error()); } ?> <table width="760" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="199" align="center" valign="top"><a href="login.html"><img src="invent-asia.gif" alt="" width="152" height="58" border="0" /></a> <script type="text/javascript" src="menu.js"></script></td> <td width="176" align="right" valign="bottom"><a href="main.php"><img src="Home.jpg" width="104" height="20" border="0"/></a></td> <td width="130" align="right" valign="bottom"><img src="View.jpg" width="104" height="20" border="0"/></td> <td width="146" align="right" valign="bottom"><a href="add_client.php"><img src="Add.jpg" width="104" height="20" border="0"/></a></td> <td width="109" align="right" valign="bottom"> </td> </tr> </table></td> </tr> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="3" bgcolor="#1B1C78"><img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td> <td width="560" bgcolor="#0076CC"><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td> </tr> </table></td> </tr> <tr> <td height="553" align="center" valign="top" bgcolor="#F3FAFE"><br /> <form name="form" action="view_client.php" method="post"> <br /> <table width="351" border="0"> <tr> <td width="137" align="left" valign="middle">SEARCH RECORD:</td> <td width="144" align="center" valign="middle"><input type="text" name="search" /></td> <td width="56" align="left" valign="middle"><input type="submit" name="btnSearch" value="Search" /></td> </tr> </table> <br /> <table border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" > <tr> <th width="80" align="center" bgcolor="#E0E8F3">Territory</th> <th width="330" align="center" bgcolor="#E0E8F3">Employer</th> <th width="160" align="center" bgcolor="#E0E8F3">Name</th> <th width="80" align="center" valign="middle" bgcolor="#E0E8F3"> </th> </tr> <?php $conn = mysql_connect('localhost','root','') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('invent-asia',$conn) or trigger_error("SQL", E_USER_ERROR); $sql = "SELECT COUNT(*) FROM records"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; $rowsperpage = 10; $totalpages = ceil($numrows / $rowsperpage); if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } if ($currentpage > $totalpages) { $currentpage = $totalpages; } if ($currentpage < 1) { $currentpage = 1; } $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT * FROM records LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); if($result) { for($i=0; $i<mysql_num_rows($result); $i++) { $id = trim(mysql_result($result, $i, "id")); $territory = trim(mysql_result($result, $i, "territory")); $employer = trim(mysql_result($result, $i, "employer")); $first_name = trim(mysql_result($result, $i, "first_name")); $last_name = trim(mysql_result($result, $i, "last_name")); echo "<td>".$territory."</td>"; echo "<td>".$employer."</td>"; echo "<td>".$last_name.", ".$first_name."</td>"; echo "<td><a href='edit_client.php?id=".$id."'>edit</a> | <a href='delete_client.php?id=".$id."'>delete</a> </td>"; echo "</tr>"; } } $range = 3; if ($currentpage > 1) { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; $prevpage = $currentpage - 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { if (($x > 0) && ($x <= $totalpages)) { if ($x == $currentpage) { echo " [<b>$x</b>] "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } if ($currentpage != $totalpages) { $nextpage = $currentpage + 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } ?> </table> <p> <br /> </p> </form> <p> </p></td> </tr> <tr> <td height="38"><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="35" align="center" bgcolor="#1B1C78" class=white><img src="images/topspacerblue.gif" alt="" width="1" height="3" /> <a href="disclaimer.html"><font color="#FFFFFF">Legal Disclaimer</font></a> </td> <td width="560" align="center" bgcolor="#0076CC" class=white><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /> Copyright © 2006 - 2010 InventAsia Limited. All rights reserved. </td> </tr> </table></td> </tr> </table> Immediate response is very well appreciated. Thank you very much ^^
  9. Good morning, First, I want to thank this forum for all the help provided to me. I am new to Php programming, and honestly, I am still not good at reading codes. I am somehow able to understand how the code is written, but I am still learning, and I know myself, I still have lots to learn. I was able to finish now my very php project, again, thanks to this site and to other forum sites I have visited, and for my friends who helped as well. The web application I made is working fine now, but as I look into it, I know that once the database is populated with information, I will be required to put up pagination on my search page. And so, I looked online for pagination tutorials. I have found some, but I have to admit, it is still hard for me to comprehend the scripts I found. Just today, I found a script that I think would be a very good implementation to the web application I made. The problem is, I am not well familiar with adopting pre-made codes to the one I did, plus the fact that I can't well understand how the code is written. Can anyone help me implement the code, and somehow provide comments on the pre-made code I found in the web? Thank you in advanced for your responses. Here's my code: <link href="add_client.css" rel="stylesheet" type="text/css"> <?PHP include("dbconnection.php"); $query = "SELECT * FROM records"; $result = array(); if(isset($_POST["btnSearch"])) { $query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' ORDER BY territory ASC" ; $result = mysql_query($query, $connection) or die(mysql_error()); } ?> <table width="760" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="199" align="center" valign="top"><a href="login.html"><img src="invent-asia.gif" alt="" width="152" height="58" border="0" /></a> <script type="text/javascript" src="menu.js"></script></td> <td width="176" align="right" valign="bottom"><a href="main.php"><img src="Home.jpg" width="104" height="20" border="0"/></a></td> <td width="130" align="right" valign="bottom"><img src="View.jpg" width="104" height="20" border="0"/></td> <td width="146" align="right" valign="bottom"><a href="add_client.php"><img src="Add.jpg" width="104" height="20" border="0"/></a></td> <td width="109" align="right" valign="bottom"> </td> </tr> </table></td> </tr> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="3" bgcolor="#1B1C78"><img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td> <td width="560" bgcolor="#0076CC"><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td> </tr> </table></td> </tr> <tr> <td height="553" align="center" valign="top" bgcolor="#F3FAFE"><br /> <form name="form" action="view_client.php" method="post"> <br /> <table width="351" border="0"> <tr> <td width="137" align="left" valign="middle">SEARCH RECORD:</td> <td width="144" align="center" valign="middle"><input type="text" name="search" /></td> <td width="56" align="left" valign="middle"><input type="submit" name="btnSearch" value="Search" /></td> </tr> </table> <br /> <table border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" > <tr> <th width="80" align="center" bgcolor="#E0E8F3">Territory</th> <th width="330" align="center" bgcolor="#E0E8F3">Employer</th> <th width="160" align="center" bgcolor="#E0E8F3">Name</th> <th width="80" align="center" valign="middle" bgcolor="#E0E8F3"> </th> </tr> <?php if($result) { for($i=0; $i<mysql_num_rows($result); $i++) { $id = trim(mysql_result($result, $i, "id")); $territory = trim(mysql_result($result, $i, "territory")); $employer = trim(mysql_result($result, $i, "employer")); $first_name = trim(mysql_result($result, $i, "first_name")); $last_name = trim(mysql_result($result, $i, "last_name")); echo "<tr>"; echo "<td>".$territory."</td>"; echo "<td>".$employer."</td>"; echo "<td>".$last_name.", ".$first_name."</td>"; echo "<td><a href='edit_client.php?id=".$id."'>edit</a> | <a href='delete_client.php?id=".$id."'>delete</a> </td>"; echo "</tr>"; } } ?> </table> <p><br /> </p> </form> <p> </p></td> </tr> <tr> <td height="38"><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="35" align="center" bgcolor="#1B1C78" class=white><img src="images/topspacerblue.gif" alt="" width="1" height="3" /> <a href="disclaimer.html"><font color="#FFFFFF">Legal Disclaimer</font></a> </td> <td width="560" align="center" bgcolor="#0076CC" class=white><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /> Copyright © 2006 - 2010 InventAsia Limited. All rights reserved. </td> </tr> </table></td> </tr> </table> And here is the link of the pagination script I found: http://www.phpeasycode.com/pagination/ I'd rather have the pagination style of the first one. Note: I am not trying to be spoon fed here, but really in this case, I have tried what I think should work, but Sorry guys. (The way my code is written, you should see that I am a noob xD)
  10. Hi schilly, thanks for the response Here's the whole code: <?php include("dbconnection.php"); if(mysql_num_rows($result) > 0) { $query = "SELECT * FROM records WHERE id = '".$_GET["id"]."'"; $result = mysql_query($query, $connection); $status = mysql_result($result, 0, "status"); $territory = mysql_result($result, 0, "territory"); $job_title = mysql_result($result, 0, "job_title"); $area_of_work = mysql_result($result, 0, "area_of_work"); $employer = mysql_result($result, 0, "employer"); $department = mysql_result($result, 0, "department"); $location = mysql_result($result, 0, "location"); $date_posted = mysql_result($result, 0, "date_posted"); $closing_date = mysql_result($result, 0, "closing_date"); $gender = mysql_result($result, 0, "gender"); $first_name = mysql_result($result, 0, "first_name"); $last_name = mysql_result($result, 0, "last_name"); $telephone_number = mysql_result($result, 0, "telephone_number"); $title = mysql_result($result, 0, "title"); $address_1 = mysql_result($result, 0, "address_1"); $address_2 = mysql_result($result, 0, "address_2"); $address_3 = mysql_result($result, 0, "address_3"); $city = mysql_result($result, 0, "city"); $country = mysql_result($result, 0, "country"); $postal_code = mysql_result($result, 0, "postal_code"); $website = mysql_result($result, 0, "website"); $email_address = mysql_result($result, 0, "email_address"); $cg_comment = mysql_result($result, 0, "cg_comment"); $date_emailed = mysql_result($result, 0, "date_emailed"); $mailing_comments= mysql_result($result, 0, "mailing_comments"); $telesales_comments= mysql_result($result, 0, "telesales_comments"); } if(isset($_POST["btnSubmit"])) { $id = $_POST["id"]; $query = "DELETE FROM records WHERE id = '".$id."'"; mysql_query($query) or die(mysql_error()); echo "<script> alert('You have successfully deleted a record'); window.location = 'view_client.php'; </script>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-family: Tahoma, Geneva, sans-serif; font-size: 12px; } --> </style></head> <body> <table width="865" height="140" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th height="69" colspan="2" bgcolor="#38619E" scope="col"><img src="header.gif" width="563" height="100" alt="" /></th> </tr> <tr> <td width="202" valign="top" bgcolor="#A1BDE1" scope="col"><p> </p> <table width="200" border="0" cellpadding="0" cellspacing="0"> <tr> <td scope="col"><table width="202" height="150" border="0" cellpadding="0" cellspacing="0"> <tr> <th height="35" colspan="5" scope="col">CONTROL PANEL</th> </tr> <tr> <td height="10"> </td> <td height="35"><a href="data_mining.php"><img src="arrow_up.png" alt="" width="30" height="30" border="0"/></a></td> <td height="10" align="left"> </td> <td height="10" align="left">MAIN PAGE</td> <td height="10" align="left"> </td> </tr> <tr> <td width="16"> </td> <td width="32" height="35"><a href="view_client.php"><img src="Search-icon.png" alt="" width="30" height="30" border="0"/></a></td> <td width="16" height="35" align="left"> </td> <td width="119" height="35" align="left">VIEW RECORD</a></td> <td width="19" align="left"> </td> </tr> <tr> <td> </td> <td height="35"><img src="addez7.png" alt="" width="30" height="30" border="0"/></td> <td height="35" align="left"> </td> <td height="35" align="left">ADD RECORD</td> <td align="left"> </td> </tr> <tr> <td height="10"> </td> <td height="10"> </td> <td height="10" align="left"> </td> <td height="10" align="left"> </td> <td height="10" align="left"> </td> </tr> </table></td> </tr> </table> <p> </p></th> <th width="657" height="600" align="center" valign="top" bgcolor="#A1BDE1" scope="col"><p> </p> <form action="delete_client.php" method="post" name="form" id="form"> <table width="560" border="0" cellpadding="1" cellspacing="0"> <tr> <td width="115"> </td> <td width="144"><input type="text" name="id" id="id" style="visibility:hidden" value="<?php echo $_GET["id"]; ?>" /></td> <td width="36"> </td> <th width="111" align="left"> Status</th> <th width="144" align="center"><?php echo $status; ?></th> </tr> <tr> <td width="115"> </td> <td width="144"> </td> <td width="36"> </td> <td width="111" align="left"> </td> <td width="144"><input name="status" type="text" id="status" style="visibility:hidden" value="<?php echo $status; ?>"/></td> </tr> <tr> <th width="115" align="left">Territory</th> <td width="144"><input type="text" name="territory" id="territory" value="<?php echo $territory; ?>" /></td> <td width="36"> </td> <th width="111" align="left">Location</th> <td width="144"><input type="text" name="location" id="location" value="<?php echo $location; ?>"/></td> </tr> <tr> <th width="115" align="left">Area of Work</th> <td width="144"><input type="text" name="area_of_work" id="area_of_work" value="<?php echo $area_of_work; ?>" /></td> <td width="36"> </td> <th width="111" align="left">Job Title</th> <td width="144"><input type="text" name="job_title" id="job_title" value="<?php echo $job_title; ?>" /></td> </tr> <tr> <th width="115" align="left">Employer</th> <td width="144"><input type="text" name="employer2" id="employer2" value="<?php echo $employer; ?>" /></td> <td width="36"> </td> <th width="111" align="left">Department</th> <td width="144"><input type="text" name="department" id="department" value="<?php echo $department; ?>"/></td> </tr> <tr> <th align="left">Date Posted</th> <td><input type="text" name="date_posted" id="date_posted" value="<?php echo $date_posted; ?>"/></td> <td> </td> <th align="left">Closing Date</th> <td><input type="text" name="closing_date" id="closing_date" value="<?php echo $closing_date; ?>"/></td> </tr> <tr> <td colspan="5" align="center"> </td> </tr> </table> <hr width="500" /> <table width="560" border="0" cellpadding="1" cellspacing="0"> <tr> <th align="left" scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> <th align="left" scope="col"> </th> <th scope="col"> </th> </tr> <tr> <th width="115" align="left" scope="col">Gender</th> <th width="144" scope="col"><input name="gender" type="text" id="gender" value="<?php echo $gender; ?>"/></th> <th width="36" scope="col"> </th> <th width="111" align="left" scope="col"> </th> <th width="144" scope="col"> </th> </tr> <tr> <th align="left" scope="col">First Name</th> <th scope="col"><input type="text" name="first_name" id="first_name" value="<?php echo $first_name; ?>"/></th> <th scope="col"> </th> <th align="left" scope="col">Last Name</th> <th scope="col"><input type="text" name="last_name" id="last_name" value="<?php echo $last_name; ?>"/></th> </tr> <tr> <th align="left" scope="col">Title</th> <th scope="col"><input type="text" name="title" id="title" value="<?php echo $title; ?>"/></th> <th scope="col"> </th> <th align="left" scope="col">Telephone</th> <th scope="col"><input type="text" name="telephone_number" id="telephone_number" value="<?php echo $telephone_number; ?>"/></th> </tr> <tr> <th align="left" scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> <th align="left" scope="col"> </th> <th scope="col"> </th> </tr> <tr> <th align="left" scope="col">Address 1</th> <th scope="col"><input type="text" name="address_1" id="address_1" value="<?php echo $address_1; ?>"/></th> <th scope="col"> </th> <th align="left" scope="col">Address 2</th> <th scope="col"><input type="text" name="address_2" id="address_2" value="<?php echo $address_2; ?>"/></th> </tr> <tr> <th align="left" scope="col">Address 3</th> <th scope="col"><input type="text" name="address_3" id="address_3" value="<?php echo $address_3; ?>"/></th> <th scope="col"> </th> <th align="left" scope="col">City</th> <th scope="col"><input type="text" name="city" id="city" value="<?php echo $city; ?>"/></th> </tr> <tr> <th align="left" scope="col">Country</th> <th scope="col"><input type="text" name="country" id="country" value="<?php echo $country; ?>"/></th> <th scope="col"> </th> <th align="left" scope="col">Postal Code</th> <th scope="col"><input type="text" name="postal_code" id="postal_code" value="<?php echo $postal_code; ?>"/></th> </tr> <tr> <th align="left" scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> <th align="left" scope="col"> </th> <th scope="col"> </th> </tr> <tr> <th align="left" scope="col">Website</th> <th scope="col"><input type="text" name="website" id="website" value="<?php echo $website; ?>"/></th> <th scope="col"> </th> <th align="left" scope="col">Email Address</th> <th scope="col"><input type="text" name="email_address" id="email_address" value="<?php echo $email_address; ?>"/></th> </tr> <tr> <th align="left" scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> <th align="left" scope="col"> </th> <th scope="col"> </th> </tr> <tr> <th align="left" scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> <th align="left" scope="col"> </th> <th scope="col"> </th> </tr> <tr> <th align="left" scope="col">CG Comment</th> <th scope="col"><input type="text" name="comment_by_cg" id="cg_comment" value="<?php echo $cg_comment; ?>"/></th> <th scope="col"> </th> <th align="left" scope="col">Date Emailed</th> <th scope="col"><input type="text" name="date_emailed" id="date_emailed" value="<?php echo $date_emailed; ?>"/></th> </tr> <tr> <th align="left" scope="col">Mailing Comments</th> <th scope="col"><input type="text" name="mailing_comments" id="mailing_comments" value="<?php echo $mailing_comments; ?>"/></th> <th scope="col"> </th> <th align="left" scope="col">Telesales Comments</th> <th scope="col"><input type="text" name="telesales_comments" id="telesales_comments" value="<?php echo $telesales_comments; ?>"/></th> </tr> <tr> <th align="left" scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> <th align="left" scope="col"> </th> <th scope="col"> </th> </tr> <tr> <th colspan="5" align="center" scope="col"><a href="view_client.php" style="text-decoration: none"> <input type="submit" name="btnSubmit" id="btnSubmit" value="Delete Record" /> <input type="submit" value=" Cancel " /> </a></th> </tr> </table> </form> <p> </p></th> </tr> </table> <center> <p><strong>Copyright © 2010 Limited. All rights reserved.</strong> </p> <p> </p> <p> </p> </center> </body> </html>
  11. Hi, can anybody check on this code? I don't have any errors in it, except that the supposedly alert after I deleted an information is not working. Thank you very much. **This is a modified code provided by a friend. It worked originally (I just lost the original file since I sold my old computer xD Here's the code: <?php include("dbconnection.php"); if(mysql_num_rows($result) > 0) { $query = "SELECT * FROM records WHERE id = '".$_GET["id"]."'"; $result = mysql_query($query, $connection); $status = mysql_result($result, 0, "status"); $territory = mysql_result($result, 0, "territory"); $job_title = mysql_result($result, 0, "job_title"); $area_of_work = mysql_result($result, 0, "area_of_work"); $employer = mysql_result($result, 0, "employer"); $department = mysql_result($result, 0, "department"); $location = mysql_result($result, 0, "location"); $date_posted = mysql_result($result, 0, "date_posted"); $closing_date = mysql_result($result, 0, "closing_date"); $gender = mysql_result($result, 0, "gender"); $first_name = mysql_result($result, 0, "first_name"); $last_name = mysql_result($result, 0, "last_name"); $telephone_number = mysql_result($result, 0, "telephone_number"); $title = mysql_result($result, 0, "title"); $address_1 = mysql_result($result, 0, "address_1"); $address_2 = mysql_result($result, 0, "address_2"); $address_3 = mysql_result($result, 0, "address_3"); $city = mysql_result($result, 0, "city"); $country = mysql_result($result, 0, "country"); $postal_code = mysql_result($result, 0, "postal_code"); $website = mysql_result($result, 0, "website"); $email_address = mysql_result($result, 0, "email_address"); $cg_comment = mysql_result($result, 0, "cg_comment"); $date_emailed = mysql_result($result, 0, "date_emailed"); $mailing_comments= mysql_result($result, 0, "mailing_comments"); $telesales_comments= mysql_result($result, 0, "telesales_comments"); } if(isset($_POST["btnSubmit"])) { $id = $_POST["id"]; $query = "DELETE FROM records WHERE id = '".$id."'"; mysql_query($query) or die(mysql_error()); echo "<script> alert('You have successfully deleted a record'); window.location = 'view_client.php'; </script>"; } ?>
  12. Hi PFMaBiSmAd, Thanks for that, problem is solved xD I am real noob here, and it's just my first time to do php programming. I was able to identify the problem I have been solving 24 hours now. The problem is the table doesn't exist on the new one. I have different tables in the dummy and the final one. Oh such an angel, thanks much much ^^
  13. Good evening, This has been bugging me for 24 hours now. I have created 2 web applications. The first one is the dummy, and the second one is the final. Basically, this two web applications does the same, just a few modifications made on the final one. I have a process of pulling out of information from the database should the user would want to modify a field. I have a problem though, the dummy one works perfectly, but the new one don't. In fact, if I use the dummy php file together with the new files, the dummy won't be working. But if I use it together with the old files, it works perfectly fine. This is the error I am getting: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\invent-asia\edit_client.php on line 46 <?php include("dbconnection.php"); if(isset($_POST["btnSubmit"])) { $id = $_POST["id"]; $territory = $_POST["territory"]; $job_title = $_POST["job_title"]; $area_of_work = $_POST["area_of_work"]; $employer = $_POST["employer"]; $location = $_POST["location"]; $job_title = $_POST["job_title"]; $date_posted = $_POST["date_posted"]; $closing_date = $_POST["closing_date"]; $department = $_POST["department"]; $gender = $_POST["gender"]; $first_name = $_POST["first_name"]; $last_name = $_POST["last_name"]; $title = $_POST["title"]; $telephone = $_POST["telephone"]; $address_1 = $_POST["address_1"]; $address_2 = $_POST["address_2"]; $address_3 = $_POST["address_3"]; $country = $_POST["country"]; $city = $_POST["city"]; $postal_code = $_POST["postal_code"]; $website = $_POST["website"]; $email_address = $_POST["email_address"]; $comment_by_cg = $_POST["comment_by_cg"]; $date_emailed = $_POST["date_emailed"]; $mailing_comments = $_POST["mailing_comments"]; $telesales_comments = $_POST["telesales_comments"]; $query = "UPDATE contacts SET territory= '".$territory."', job_title = '".$job_title."', area_of_work = '".$area_of_work."', employer = '".$employer."', location = '".$location."', job_title = '".$job_title."', employer = '".$employer."', date_posted = '".$date_posted."', department = '".$department."', closing_date = '".$closing_date."', gender = '".$gender."', first_name = '".$first_name."', last_name = '".$last_name."', title = '".$title."', telephone = '".$telephone."', address_1 = '".$address_1."', address_2 = '".$address_2."', address_3 = '".$address_3."', country = '".$country."', city = '".$city."', postal_code = '".$postal_code."', website = '".$website."', email_address = '".$email_address."', comment_by_cg = '".$comment_by_cg."', date_emailed = '".$date_emailed."', mailing_comments = '".$mailing_comments."', telesales_comments = '".$telesales_comments."' WHERE id = '".$id."'"; mysql_query($query) or die(mysql_error()); echo "<script> alert('You have successfully updated a record'); window.location = 'view.php'; </script>"; } $query = "SELECT * FROM contacts WHERE id = '".$_GET["id"]."'"; $result = mysql_query($query, $connection); if(mysql_num_rows($result) > 0) - THIS IS THE 46th LINE IN THE CODE { $territory = mysql_result($result,0, "territory"); $job_title = mysql_result($result, 0, "job_title"); $area_of_work = mysql_result($result, 0, "area_of_work"); $employer = mysql_result($result, 0, "employer"); $status = mysql_result($result, 0, "status"); $location = mysql_result($result,0, "location"); $department = mysql_result($result,0, "department"); $date_posted = mysql_result($result,0, "date_posted"); $closing_date = mysql_result($result,0, "closing_date"); $gender = mysql_result($result,0, "gender"); $first_name = mysql_result($result,0, "first_name"); $last_name = mysql_result($result,0, "last_name"); $title = mysql_result($result,0, "title"); $telephone = mysql_result($result,0, "telephone"); $address_1 = mysql_result($result,0, "address_1"); $address_2 = mysql_result($result,0, "address_2"); $address_3 = mysql_result($result,0, "address_3"); $city = mysql_result($result,0, "city"); $country = mysql_result($result,0, "country"); $postal_code = mysql_result($result,0, "postal_code"); $website = mysql_result($result,0, "website"); $email_address = mysql_result($result,0, "email_address"); $comment_by_cg = mysql_result($result,0, "comment_by_cg"); $date_emailed = mysql_result($result,0, "date_emailed"); $mailing_comments = mysql_result($result,0, "mailing_comments"); $telesales_comments = mysql_result($result,0, "telesales_comments"); } ?> Can anyone help me solve this issue? This is the only feature in my project that is left bugged Your quick response is well appreciated. Thank you very much
  14. Hello, I am having a problem with retrieving information from my database. I am kinda new in programming industry, and with the error message displayed, I can't pinpoint what went wrong in the code. Here is the PHP code: <?php include("dbconnection.php"); if(isset($_POST["btnSubmit"])) { $id = $_POST["id"]; $territory = $_POST["territory"]; $job_title = $_POST["job_title"]; $area_of_work = $_POST["area_of_work"]; $employer = $_POST["employer"]; $location = $_POST["location"]; $job_title = $_POST["job_title"]; $date_posted = $_POST["date_posted"]; $closing_date = $_POST["closing_date"]; $department = $_POST["department"]; $gender = $_POST["gender"]; $first_name = $_POST["first_name"]; $last_name = $_POST["last_name"]; $title = $_POST["title"]; $telephone = $_POST["telephone"]; $address_1 = $_POST["address_1"]; $address_2 = $_POST["address_2"]; $address_3 = $_POST["address_3"]; $country = $_POST["country"]; $city = $_POST["city"]; $postal_code = $_POST["postal_code"]; $website = $_POST["website"]; $email_address = $_POST["email_address"]; $cg_comment = $_POST["cg_comment"]; $date_emailed = $_POST["date_emailed"]; $mailing_comments = $_POST["mailing_comments"]; $telesales_comments = $_POST["telesales_comments"]; $query = "UPDATE contacts SET territory= '".$territory."', job_title = '".$job_title."', area_of_work = '".$area_of_work."', employer = '".$employer."', location = '".$location."', job_title = '".$job_title."', employer = '".$employer."', date_posted = '".$date_posted."', department = '".$department."', closing_date = '".$closing_date."', gender = '".$gender."', first_name = '".$first_name."', last_name = '".$last_name."', title = '".$title."', telephone = '".$telephone."', address_1 = '".$address_1."', address_2 = '".$address_2."', address_3 = '".$address_3."', country = '".$country."', city = '".$city."', postal_code = '".$postal_code."', website = '".$website."', email_address = '".$email_address."', cg_comment = '".$cg_comment."', date_emailed = '".$date_emailed."', mailing_comments = '".$mailing_comments."', telesales_comments = '".$telesales_comments."' WHERE id = '".$id."'"; mysql_query($query) or die(mysql_error()); echo "<script> alert('You have successfully updated a record'); window.location = 'view.php'; </script>"; } $query = "SELECT * FROM contacts WHERE id = '".$_GET["id"]."'"; $result = mysql_query($query, $connection); if(mysql_num_rows($result) > 0) { $territory = mysql_result($result,0, "territory"); $job_title = mysql_result($result, 0, "job_title"); $area_of_work = mysql_result($result, 0, "area_of_work"); $employer = mysql_result($result, 0, "employer"); $status = mysql_result($result, 0, "status"); $location = mysql_result($result,0, "location"); $department = mysql_result($result,0, "department"); $date_posted = mysql_result($result,0, "date_posted"); $closing_date = mysql_result($result,0, "closing_date"); $gender = mysql_result($result,0, "gender"); $first_name = mysql_result($result,0, "first_name"); $last_name = mysql_result($result,0, "last_name"); $title = mysql_result($result,0, "title"); $telephone = mysql_result($result,0, "telephone"); $address_1 = mysql_result($result,0, "address_1"); $address_2 = mysql_result($result,0, "address_2"); $address_3 = mysql_result($result,0, "address_3"); $city = mysql_result($result,0, "city"); $country = mysql_result($result,0, "country"); $postal_code = mysql_result($result,0, "postal_code"); $website = mysql_result($result,0, "website"); $email_address = mysql_result($result,0, "email_address"); $cg_comment = mysql_result($result,0, "cg_comment"); $date_emailed = mysql_result($result,0, "date_emailed"); $mailing_comments = mysql_result($result,0, "mailing_comments"); $telesales_comments = mysql_result($result,0, "telesales_comments"); } ?> The error I am getting is: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\invent-asia\edit_client.php on line 268 Line 268 in the code is: Immediate response is well appreciated. Thank you very much!
  15. Awww you're an angel petroz, it worked now xD I've been doing this for almost a week now aww thank you very very much for the help xD now I need to understand what happened ^^ Thanks much again! Seriously, what happened in the code? I only see the $result = "array" added xD
  16. Hi petroz Thanks for your response. Yes, I am using a form. However, if I try to put the query inside if(isset($_POST["btnSearch"])), I am getting a "Query was empty" message.
  17. Good evening, I am currently doing a web application which requires pulling out of data from the database. I am still a novice in the programming industry, and is still seeking help from my colleagues and of course forum sites like phpdn. I have an existing code which my friend provided me. I have already done some modifications with the code. I have a problem though with the code, it executes database query upon loading of the page. I do understand how the code works, however, I am not able to modify the code to disallow the execution of query upon loading of page. Here is the code: <?PHP include("dbconnection.php"); $query = "SELECT * FROM records"; if(isset($_POST["btnSearch"])) { $query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' " ; } $result = mysql_query($query, $connection) or die(mysql_error()); ?> I do know that this php code, the way it is written, is supposed to do that - to select data from my database (This code was provided by a friend). But my requirement for the project is actually to give it a search engine and display the information based from the search query. I have a search engine already together with the code, and it works pretty well. What I must do is to disallow the pulling of data from the first load, but just pull data if the search engine is used. Here's the whole code: <link href="add_client.css" rel="stylesheet" type="text/css"> <?PHP include("dbconnection.php"); $query = "SELECT * FROM records"; if(isset($_POST["btnSearch"])) { $query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' " ; } $result = mysql_query($query, $connection) or die(mysql_error()); ?> <table width="760" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="199" align="center" valign="top"><a href="login.html"><img src="asia.gif" alt="" width="152" height="58" border="0" /></a> <script type="text/javascript" src="menu.js"></script></td> <td width="176" align="right" valign="bottom"><a href="main.php"><img src="Home.jpg" width="104" height="20" border="0"/></a></td> <td width="130" align="right" valign="bottom"><img src="View.jpg" width="104" height="20" border="0"/></td> <td width="146" align="right" valign="bottom"><a href="add_client.php"><img src="Add.jpg" width="104" height="20" border="0"/></a></td> <td width="109" align="right" valign="bottom"> </td> </tr> </table></td> </tr> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="3" bgcolor="#1B1C78"><img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td> <td width="560" bgcolor="#0076CC"><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td> </tr> </table></td> </tr> <tr> <td height="553" align="center" valign="top" bgcolor="#F3FAFE"><br /> <form name="form" action="view_client.php" method="post"> <table width="351" border="0"> <tr> <td width="137" align="left" valign="middle">SEARCH RECORD:</td> <td width="144" align="center" valign="middle"><input type="text" name="search" /></td> <td width="56" align="left" valign="middle"><input type="submit" name="btnSearch" value="Search" /></td> </tr> </table> <br /> <table width="680" border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" > <tr> <th width="100" align="center" bgcolor="#E0E8F3">Territory</th> <th width="110" align="center" bgcolor="#E0E8F3">Employer</th> <th width="110" align="center" bgcolor="#E0E8F3">Job Title</th> <th width="50" align="center" bgcolor="#E0E8F3">Title</th> <th width="110" align="center" bgcolor="#E0E8F3">First Name</th> <th width="110" align="center" bgcolor="#E0E8F3">Last Name</th> <th width="70" align="center" valign="middle" bgcolor="#E0E8F3"> </th> </tr> <?php if($result) { for($i=0; $i<mysql_num_rows($result); $i++) { $id = trim(mysql_result($result, $i, "id")); $territory = trim(mysql_result($result, $i, "territory")); $employer = trim(mysql_result($result, $i, "employer")); $job_title = trim(mysql_result($result, $i, "job_title")); $title = trim(mysql_result($result, $i, "title")); $first_name = trim(mysql_result($result, $i, "first_name")); $last_name = trim(mysql_result($result, $i, "last_name")); echo "<tr>"; echo "<td>".$territory."</td>"; echo "<td>".$employer."</td>"; echo "<td>".$job_title."</td>"; echo "<td>".$title."</td>"; echo "<td>".$first_name."</td>"; echo "<td>".$last_name."</td>"; echo "<td><a href='admin_edit.php?id=".$id."'>edit</a> | <a href='admin_delete.php?id=".$id."'>del</a> </td>"; echo "</tr>"; } } ?> </table> <br /> </form> <p> </p></td> </tr> <tr> <td height="38"><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="35" align="center" bgcolor="#1B1C78" class=white><img src="images/topspacerblue.gif" alt="" width="1" height="3" /> <a href="disclaimer.html"><font color="#FFFFFF">Legal Disclaimer</font></a> </td> <td width="560" align="center" bgcolor="#0076CC" class=white><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /> Copyright © 2006 - 2010 Limited. All rights reserved. </td> </tr> </table></td> </tr> </table> Immediate response is well appreciated. Thank you very much!
×
×
  • 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.