Hi! I have started learn about Query and PHP, and i don't know what to do next. I have made table with query help i can show in table records from my Database, so far i have well, but next what i want to do is every record in table make somthing like a page with full information of record, and here is my problem i don't know how to do it. This function is similar like torrent trackers use it. User go to browse section and find what him need and click on name and it's open template where he can find full information about torrent. And it's exectly that what i want, a page template which will show current ID record whith information. Mybe you know where i can get redy version, then post it bellow name or link. I will add my code source too, mybe that is prety simple, but i can't figurete how it works. If you have some questions then just ask i will try to respond! So thanks you allredy and i will wait Reply!

P.s - My code is little messy! (devil)
**
With regards,
Helvijs
**

<html>
<head>
<title>Tabula</title>
    <style type="text/css">
    body{
        font-size:0.8em;
        font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif;
    }
    table thead td{
        font-weight:bold;
        cursor:pointer;
    }
    .highlightedColumn{
      background-color:#CCC;
     } 

    .myTable {
    border: 2px;
    } 
    </style>
    <script type="text/javascript">
    var tableWidget_okToSort = true;
    var tableWidget_arraySort = new Array();
    tableWidget_tableCounter = 1;
    var activeColumn = new Array();
    var currentColumn = false;

    function sortNumeric(a,b){

        a = a.replace(/,/,'.');
        b = b.replace(/,/,'.');
        a = a.replace(/[^\d\.\/]/g,'');
        b = b.replace(/[^\d\.\/]/g,'');
        if(a.indexOf('/')>=0)a = eval(a);
        if(b.indexOf('/')>=0)b = eval(b);
        return a/1 - b/1;
    }


    function sortString(a, b) {

      if ( a.toUpperCase() < b.toUpperCase() ) return -1;
      if ( a.toUpperCase() > b.toUpperCase() ) return 1;
      return 0;
    }

    function sortTable()
    {
        if(!tableWidget_okToSort)return;
        tableWidget_okToSort = false;
        /* Getting index of current column */
        var obj = this;
        var indexThis = 0;
        while(obj.previousSibling){
            obj = obj.previousSibling;
            if(obj.tagName=='TD')indexThis++;
        }

        if(this.getAttribute('direction') || this.direction){
            direction = this.getAttribute('direction');
            if(navigator.userAgent.indexOf('Opera')>=0)direction = this.direction;
            if(direction=='ascending'){
                direction = 'descending';
                this.setAttribute('direction','descending');
                this.direction = 'descending';
            }else{
                direction = 'ascending';
                this.setAttribute('direction','ascending');
                this.direction = 'ascending';
            }
        }else{
            direction = 'ascending';
            this.setAttribute('direction','ascending');
            this.direction = 'ascending';
        }

        var tableObj = this.parentNode.parentNode.parentNode;
        var tBody = tableObj.getElementsByTagName('TBODY')[0];

        var widgetIndex = tableObj.getAttribute('tableIndex');
        if(!widgetIndex)widgetIndex = tableObj.tableIndex;

        if(currentColumn)currentColumn.className='';
        document.getElementById('col' + widgetIndex + '_' + (indexThis+1)).className='highlightedColumn';
        currentColumn = document.getElementById('col' + widgetIndex + '_' + (indexThis+1));


        var sortMethod = tableWidget_arraySort[widgetIndex][indexThis]; // N = numeric, S = String
        if(activeColumn[widgetIndex] && activeColumn[widgetIndex]!=this){
            if(activeColumn[widgetIndex])activeColumn[widgetIndex].removeAttribute('direction');
        }

        activeColumn[widgetIndex] = this;

        var cellArray = new Array();
        var cellObjArray = new Array();
        for(var no=1;no<tableObj.rows.length;no++){
            var content= tableObj.rows[no].cells[indexThis].innerHTML+'';
            cellArray.push(content);
            cellObjArray.push(tableObj.rows[no].cells[indexThis]);
        }

        if(sortMethod=='N'){
            cellArray = cellArray.sort(sortNumeric);
        }else{
            cellArray = cellArray.sort(sortString);
        }

        if(direction=='descending'){
            for(var no=cellArray.length;no>=0;no--){
                for(var no2=0;no2<cellObjArray.length;no2++){
                    if(cellObjArray[no2].innerHTML == cellArray[no] && !cellObjArray[no2].getAttribute('allreadySorted')){
                        cellObjArray[no2].setAttribute('allreadySorted','1');
                        tBody.appendChild(cellObjArray[no2].parentNode);
                    }
                }
            }
        }else{
            for(var no=0;no<cellArray.length;no++){
                for(var no2=0;no2<cellObjArray.length;no2++){
                    if(cellObjArray[no2].innerHTML == cellArray[no] && !cellObjArray[no2].getAttribute('allreadySorted')){
                        cellObjArray[no2].setAttribute('allreadySorted','1');
                        tBody.appendChild(cellObjArray[no2].parentNode);
                    }
                }
            }
        }

        for(var no2=0;no2<cellObjArray.length;no2++){
            cellObjArray[no2].removeAttribute('allreadySorted');
        }

        tableWidget_okToSort = true;


    }
    function initSortTable(objId,sortArray)
    {
        var obj = document.getElementById(objId);
        obj.setAttribute('tableIndex',tableWidget_tableCounter);
        obj.tableIndex = tableWidget_tableCounter;
        tableWidget_arraySort[tableWidget_tableCounter] = sortArray;
        var tHead = obj.getElementsByTagName('THEAD')[0];
        var cells = tHead.getElementsByTagName('TD');
        for(var no=0;no<cells.length;no++){
            if(sortArray[no]){
                cells[no].onclick = sortTable;
            }else{
                cells[no].style.cursor = 'default';
            }
        }
        for(var no2=0;no2<sortArray.length;no2++){   /* Right align numeric cells */
            if(sortArray[no2] && sortArray[no2]=='N')obj.rows[0].cells[no2].style.textAlign='right';
        }

        tableWidget_tableCounter++;
    }
</script>
</head>
<body>

<?php
$username="YourName";
$password="YourPW";
$database="YourDB";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM srots";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<br />
<br />
<table id="myTable" border="1">
    <colgroup>
        <col id="col1_1"></col>
        <col id="col1_2"></col>
        <col id="col1_3"></col>
        <col id="col1_4"></col>
        <col id="col1_5"></col>
        <col id="col1_6"></col>
        <col id="col1_7"></col>
    </colgroup>
    <thead>
        <tr>
            <td>ID</td>
            <td>Bilde</td>
            <td>Apraksts</td>
            <td>Gads</td>
            <td>Dzineja Tilp.</td>
            <td>Krāsa</td>
            <td>Opcijas</td>
        </tr>
    </thead>
    <tbody>
    <?php
$i=0;
while ($i < $num) {

$f0=mysql_result($result,$i,"id");
$f1=mysql_result($result,$i,"a2");
$f2=mysql_result($result,$i,"a3");
$f3=mysql_result($result,$i,"a4");
$f4=mysql_result($result,$i,"a5");
$f5=mysql_result($result,$i,"a6");
$f6=mysql_result($result,$i,"a7");
$f7=mysql_result($result,$i,"a8");
$f8=mysql_result($result,$i,"a9");
$f9=mysql_result($result,$i,"a10");
$f10=mysql_result($result,$i,"a11");
$f11=mysql_result($result,$i,"a12");
$f12=mysql_result($result,$i,"a13");
$f13=mysql_result($result,$i,"a14");
$f14=mysql_result($result,$i,"a15");
$f15=mysql_result($result,$i,"a16");
$f16=mysql_result($result,$i,"a17");
$f17=mysql_result($result,$i,"a18");
$f18=mysql_result($result,$i,"a19");
$f19=mysql_result($result,$i,"a20");
$f20=mysql_result($result,$i,"a21");
$f21=mysql_result($result,$i,"a22");
$f22=mysql_result($result,$i,"a23");
$f23=mysql_result($result,$i,"a24");
$f24=mysql_result($result,$i,"a25");
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f0; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><img src="<?php echo $f1; ?>" /></font></td>
<td><font face="Arial, Helvetica, sans-serif"><b><a href="http://localhost/table/page.php?id=<?php echo $f0; ?>"><?php echo $f2; ?></a></b></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><a href="http://localhost/table/edit.php?id=<?php echo $f0; ?>">Edit</a></font></td>
</tr>

    </tbody>
    <?php
$i++;
}
?>
</table>
<script type="text/javascript">
initSortTable('myTable',Array('S','N','S','N','S','N','S'));
</script>

</body>
</html>

P.s I'm using sortable table from dhtmlgoodies (i think so, i can't remeber where i get this)

And SQL for testing

-- 
-- Tabulas struktūra tabulai `srots`
-- 

CREATE TABLE `srots` (
  `id` int(11) NOT NULL auto_increment,
  `a2` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a3` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a4` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a5` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a6` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a7` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a8` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a9` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a10` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a11` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a12` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a13` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a14` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a15` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a16` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a17` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a18` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a19` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a20` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a21` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a22` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a23` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a24` varchar(255) collate utf8_unicode_ci NOT NULL,
  `a25` varchar(255) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;

-- 
-- Dati tabulai `srots`
-- 

INSERT INTO `srots` VALUES (1, 'thumb/thumbs/1.jpg', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2');
INSERT INTO `srots` VALUES (2, 'thumb/thumbs/2.jpg', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2');
INSERT INTO `srots` VALUES (3, 'thumb/thumbs/3.jpg', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2');
INSERT INTO `srots` VALUES (4, 'thumb/thumbs/4.jpg', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2');

It's have test values!

What you would have to do is make (for example) a link to detail.php?id=1 (where 1 will be the ID from the database). In your detail script you can use $_GET['id'] to query your database for this particular record, and output all details in whatever way you want.

Hmm... Could you make some sample for detail.php? I still can't figurete how he can take only records from that id, or its take id from the adress bar where would be : http://mypage.com/detail.php?id=1 from this part detail.php?id=1?

if(ctype_digit($_GET['id'])){
    $id = $_GET['id'];
}else{
    $id = 0;
}
$query="SELECT * FROM srots where id = {$_GET['id']}";
$result=mysql_query($query);
if($result !== false){
    $data = mysql_fetch_assoc($result);
    var_dump($data);
}else{
    echo 'bad id';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.