marukochan Posted January 15, 2007 Share Posted January 15, 2007 Can somebody give me an idea on how to it? What I want to do is to have a list of records and when the user click view button at that particular record, it will display the full details of that record.TQ Quote Link to comment Share on other sites More sharing options...
btherl Posted January 15, 2007 Share Posted January 15, 2007 Normally this would be done with MySQL. Is that what you are using currently?Can you post the code you have now (if any)? Otherwise, can you tell us where you are at (eg, still desigining the script) so we can better help you?Thanks! Quote Link to comment Share on other sites More sharing options...
marukochan Posted January 15, 2007 Author Share Posted January 15, 2007 OK. Here is the code. Current code will only display the Company Name (at // Display Area). What I want to do is to have a view button at each record and when the user click that button, it will display full details of that particular record.TQCode<?php$title = "Project Database Page";include ("page_function.php");header_start();header_user();echo ("<p><b>Company List List</b></p>");connect_database();// Set page to zero if no current pageif(!isset($_GET['page'])){ $page = 1;} else { $page = $_GET['page'];}// Set number of records per page$max_results = 10;// Limit for current page$from = (($page * $max_results) - $max_results); // Query on current page$sql = mysql_query("SELECT * FROM company LIMIT $from, $max_results");// Display Areaif(mysql_num_rows($sql) == 0){ echo("Nothing to Display!"); } $bgcolor = "#E0E0E0"; // light gray echo("<table>"); while($row = mysql_fetch_array($sql)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor."><td width=60%>"); echo($row["company_name"]); echo("</td></tr>"); } echo("</table>"); echo("</br>");// End Display Area// Find out total number of records$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM company"),0);// Find out total number of pages$total_pages = ceil($total_results / $max_results);if ($page < 1) { $page = 1; } elseif ($page > $total_pages) { $pagenum = $total_pages; } //Set query range$max = 'limit ' .($page - 1) * $max_results .',' .$max_results;$data_p = mysql_query("SELECT * FROM company $max") or die(mysql_error()); while($info = mysql_fetch_array( $data_p )) { } // Link for previous pageif($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><b>Previous </b></a> ";}for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; }}// Link for next pageif($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\"><b> Next</b></a>";}echo "</center>";footer();?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted January 15, 2007 Share Posted January 15, 2007 Ok, to start with you need to make this parts here:echo($row["company_name"]);A link. If you have a unique ID, then pass that in the query string, if not, then use the company:[code]<?phpecho "<a href='viewcompany.php?id=".$row["id"]."'>".$row["company_name"]."</a>");?>[/code]Then, on your new page, which ive called viewcompany.php:[code]<?php$id = mysql_real_escape_string($_GET['id']);$sql = "SELECT * FROM `company` WHERE `id`='$id'";$result = mysql_query($sql) or die(mysql_error());?>[/code]Ive not added anything about outputting the code because ive no idea how you were planning on layout it out or what information you have. But thats the gerneral idea. Also, if you do need to change it to using the company name rather than an ID, then you'll have to modify it accordingly. Quote Link to comment Share on other sites More sharing options...
marukochan Posted January 15, 2007 Author Share Posted January 15, 2007 Thanks a lot for your help,GingerRobot. My script is already running as I want it .......... ;D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.