Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Dinamicko generisanje named anchor php+mysql

[es] :: PHP :: Dinamicko generisanje named anchor php+mysql

[ Pregleda: 1485 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

yooe
Marko Španović
Beograd

Član broj: 30661
Poruke: 7
*.83.beocity.net.



Profil

icon Dinamicko generisanje named anchor php+mysql10.05.2008. u 10:58 - pre 150 meseci
Imam bazu podataka baza_vesti,sa jednom tabelom tabela_vesti
i cetri kolone u tabeli:vesti_id (int),naslov(txt),datum(txt),tekst(txt).

Izgled index.php izgleda ovako:
Code:

<html>
    <head><title>PREGLED VESTI</title></head>
    <body>        
        <?php
            if([email protected]_connect("localhost","root","")){
                die("POVEZIVANJE NA MYSQL BAZU NIJE USPELO");
            }
            if(!mysql_select_db("baza_vesti",$db)){
                die("GRESKA PRILIKOM BIRANJA BAZE");
            }
            $sql="SELECT vesti_id,naslov,datum,tekst FROM tabela_vesti";
            
            $q=mysql_query($sql)                        
            
        ?>        
        <table>            
            <?php
                while($redak=mysql_fetch_assoc($q)){
            ?>
            <tr>                
                <td><?=$redak['naslov']?> </td><td><?=$redak['datum']?></td>
            </tr>
            <tr>                
                <td> <?=$redak['tekst']?></td>
            </tr>                                
            <?php 
                }             
            ?>
        </table>
    </body>
</html>


Kako dinamicki da generisem named anchor
tako da mi index.php prikazije vesti kao na stranici:www.gsp.co.yu/novosti1.htm

Nesto tipa ovako:
Code:

<html>
    <head><title>PREGLED VESTI</title></head>
    <body>        
        <?php
            if([email protected]_connect("localhost","root","")){
                die("POVEZIVANJE NA MYSQL BAZU NIJE USPELO");
            }
            if(!mysql_select_db("baza_vesti",$db)){
                die("GRESKA PRILIKOM BIRANJA BAZE");
            }
            $sql="SELECT vesti_id,naslov,datum,tekst FROM tabela_vesti";
            
            $q=mysql_query($sql)                        
            
        ?>        
        <table>            
            <?php
                while($redak=mysql_fetch_assoc($q)){
            ?>
            <tr>                
                <td><a href=#<?=$redak['vesti_id']?>> <?=$redak['naslov']?></a></td>
            </tr>
            <?php 
                }             
            ?>
            <?php
                while($redak=mysql_fetch_assoc($q)){
            ?>
            <tr>                
                <td><a name=<?=$redak['vesti_id']?><?=$redak['naslov']?></a> </td><td><?=$redak['datum']?></td>
            </tr>
            <tr>                
                <td> <?=$redak['tekst']?></td>
            </tr>                                
            <?php 
                }             
            ?>
        </table>
    </body>
</html>
 
Odgovor na temu

emranonline
Emran Bajrami
Tu i tamo

Član broj: 105825
Poruke: 179
82.114.75.*



+1 Profil

icon Re: Dinamicko generisanje named anchor php+mysql10.05.2008. u 18:05 - pre 150 meseci
evo ja sam malo pregledao kod i prepravio
Code:
<html>
    <head><title>PREGLED VESTI</title></head>
    <body>        
        <?php
            if([email protected]_connect("localhost","root","")){
                die("POVEZIVANJE NA MYSQL BAZU NIJE USPELO");
            }
            if(!mysql_select_db("baza_vesti",$db)){
                die("GRESKA PRILIKOM BIRANJA BAZE");
            }
            $sql="SELECT vesti_id,naslov,datum,tekst FROM tabela_vesti";
            
            $q=mysql_query($sql);
            $w=mysql_query($sql);    
            
        ?>        
        <table>            
            <?php
                while($redak=mysql_fetch_assoc($q)){
            ?>
            <tr>                
                <td><a href=#<?=$redak['vesti_id']?>> <?=$redak['naslov']?></a></td>
            </tr>
            <?php 
                }             
            ?>
            <?php
                while($red=mysql_fetch_assoc($w)){
            ?>
            <tr>                
                <td><a name='<?=$red['vesti_id']?>'><?=$red['naslov']?></a> </td><td><?=$red['datum']?></td>
            </tr>
            <tr>                
                <td> <?=$red['tekst']?></td>
            </tr>                                
            <?php 
                }             
            ?>
        </table>
    </body>
</html>
 
Odgovor na temu

yooe
Marko Španović
Beograd

Član broj: 30661
Poruke: 7
*.83.beocity.net.



Profil

icon Re: Dinamicko generisanje named anchor php+mysql10.05.2008. u 21:11 - pre 150 meseci
To je to,
hvala.
 
Odgovor na temu

[es] :: PHP :: Dinamicko generisanje named anchor php+mysql

[ Pregleda: 1485 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.