dislaying and updating results from MySQL dbase

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
CivicDude
Forum Newbie
Posts: 3
Joined: Thu Feb 26, 2004 8:30 am
Location: Bournemouth, UK

dislaying and updating results from MySQL dbase

Post by CivicDude »

hi ya - post from a newbie! am writing a script that returns results from a mysql dbase which i have got working and returning reults. however - there are loads of results and each record contains 16 fields so there is a lot of data to display. How is it possible to display results but have each record displayed on a different page? any help in pseudocode would help and then i'll come back with the code. thanks for any help - an example would be superb! 8)
CivicDude
Forum Newbie
Posts: 3
Joined: Thu Feb 26, 2004 8:30 am
Location: Bournemouth, UK

Post by CivicDude »

this is a rough version of the code that displays the results from the table in the MySQL dbase based on what the user searches for. This code already works but it displays all the results on one page - how do you put the results on a different page for each record?

Code: Select all

<?php
include ("connect.inc");

//Select statement to find the corresponding number to the Status_ID, E.G. Open corresponds to number 3
$STATUS = mysql_query("SELECT STATUS_ID FROM STATUS where STATUS_NAME='$STATUS_NAME'");
$num_rows = mysql_num_rows($STATUS);
while ($get_info = mysql_fetch_row($STATUS)){
foreach ($get_info as $STATUS_NO)

echo "$STATUS_NO";

$query = "SELECT * FROM track WHERE STATUS_ID = '$STATUS_NO'";
$result = mysql_query($query)
          or die ("Couldn't execute query");
echo "<table border=1>";
while ($row = mysql_fetch_array($result,MYSQL_ASSOC) )
{
echo "<tr><td>Track ID</td></tr>\n";
echo "<tr>\n";
echo "<td>{$row['TRACK_ID']}</td>\n";
echo "<td>{$row['PRODUCT_ID']}</td>\n";
echo "<td>{$row['REPORT_ID']}</td>\n";
echo "<td>{$row['REP_VERSION']}</td>\n";
echo "<td>{$row['REL_VERSION']}</td>\n";
echo "<td>{$row['STATUS_ID']}</td>\n";
echo "<td>{$row['SUBMITTED BY']}</td>\n";
echo "<td>{$row['ASSIGNED TO']}</td>\n";
echo "<td>{$row['RESOLVED BY']}</td>\n";
echo "<td>{$row['TITLE']}</td>\n";
echo "<td>{$row['CRIT FAULT']}</td>\n";
echo "<td>{$row['CUST_ID']}</td>\n";
echo "<td>{$row['EXT_REF']}</td>\n";
echo "<td>{$row['DOC_CHANGE']}</td>\n";
echo "<td>{$row['INJECTION_ID']}</td>\n";
echo "<td>{$row['INVESTIGATE']}</td>\n";

echo "<\table>\n";
}
}
?>
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

here
and also check out HotScripts for other pagination tutorials
CivicDude
Forum Newbie
Posts: 3
Joined: Thu Feb 26, 2004 8:30 am
Location: Bournemouth, UK

pagination

Post by CivicDude »

thanks for th reply. gone thru the code and have a problem with the hyperlinks showing up as plain text. code is as follows:

any help would be great. cheers

Code: Select all

<?php
 if(($totalrows - ($limit * $page)) > 0){
        $pagenext = $page++;
         
        echo("<a href="test.php?page=$pagenext">NEXT".$limit."</a>");
    }else{
        echo("NEXT".$limit);
    }
    
    mysql_free_result($result);

?>
<?php

?>
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

I personaly prefer:

Code: Select all

echo '<a href="test.php?page=' . $pagenext . '">NEXT' . $limit . '</a>';
If that helps...
Post Reply