Thread: Templates

  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Rep Power
    Hi Gurus !!!

    Please, look and run this codes:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    # conf.php

    $hostname = "localhost";
    $username = "root";
    $password = "";
    $dbname = "projeto";

    mysql_connect($hostname,$username,$password) or die ("Erro: Conexão não estabelecida");
    mysql_select_db("$dbname") or die ("Erro: Não foi possível acessar o banco de dados");

    #HTML - TAGS
    $temp = str_replace("<%ID%>", $id, $temp);
    $temp = str_replace("<%Categoria%>", $categoria, $temp);
    $temp = str_replace("<%Nome%>", $nome, $temp);
    $temp = str_replace("<%Texto%>", $texto, $temp);
    $temp = str_replace("<%Imagem%>", $imagem, $temp);
    $temp = str_replace("<%Links%>", $links, $temp);



    # teste.php


    Function OpenTemplate($tempname) {
    Global $id,$categoria,$nome,$texto,$imagem,$links;


    $tempfile = fopen("$tempurl/$tempname", "r");

    $temp = fgets($tempfile,255);

    $result = mysql_query("select * from empresa");

    function links($result) {
    Global $id,$categoria,$nome,$texto,$imagem,$links;
    while($row = mysql_fetch_array($result)) {
    $id = $row["ID"];
    $categoria = $row["Categoria"];
    $nome = $row["Nome"];
    $texto = $row["Texto"];
    $imagem = $row["Imagem"];

    $links = links($result);




    <!-- links.html -->
    <div align="center"><center>
    <table border="0" width="100%">
    <td width="33%"></td>
    <td width="33%"><p>
    <td width="34%"></td>


    <!-- teste.html -->
    <div align="center"><center>
    <table border="0" width="100%">
    <td width="33%"></td>
    <td width="33%"><p>
    <td width="34%"></td>


    OK ?!?! ... I'm trying to run this, but there are something that I can't see that's wrong.

    I want to use the tag <%Links%> to list all rows from my table in the teste.html template, but I receive only the last row from the table.

    Any ideas to solve this ???



  2. #2
  3. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    First thing that comes to mind is that the <% is typically associated with ASP, and PHP can be configured to interpret that instead of or the same as <?php or <?

    So.. I could be way wrong, but maybe that's the problem.

    You may get away with using <%% instead.

    Or simple using <variable>

    or just %variable%

    SnR Graphics,
    Low Cost Hosting and Web Development.

Similar Threads

  1. Replies: 0
    Last Post: February 10th, 2004, 04:43 PM
  2. Nested templates in Dreamweaver MX 2004
    By switcha in forum Web Design Help
    Replies: 2
    Last Post: January 30th, 2004, 08:35 AM
  3. a good templates system ?
    By amrgo in forum PHP Development
    Replies: 3
    Last Post: January 20th, 2004, 09:12 PM
  4. Starting with templates question
    By Ramiro S in forum PHP Development
    Replies: 6
    Last Post: February 5th, 2002, 03:45 PM
  5. templates, templates, templates..
    By MkJnr in forum PHP Development
    Replies: 7
    Last Post: January 20th, 2002, 09:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo