SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Guys...

    I am new at this php stuff and can't figure this out. I know it is simple, but it's not for me.

    The script below generates a list of domains in my database as well as it's price. I would like the domain name it generates to be an active link to the following address. It needs the domain name in the address... that is why I put the $domain there. Let me know if this make sense...

    Thanks,

    Doug

    www.dotdealers.com/admin.php?dname=$domain&actedit=Edit


    Here's the script so far...

    <?
    mysql_connect("localhost","xxxxxx","xxxxxxx");
    mysql_select_db("xxxxxxxxx");

    $query = "SELECT * FROM dd_domains";
    $result = mysql_query($query);

    echo "<html><body bgcolor=\"#FFFFFF\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"4\"><tr><td><b>domain</b></td><td><b>price</b></td></tr>";
    while($row = mysql_fetch_array($result))
    {
    $price = $row['priceb'];
    $domain = $row['name'];

    echo "<tr><td>$domain</td><td>$price</td></tr>";
    }

    echo "</table></body></html>";

    ?>

  2. #2
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how about this :


    echo "<tr><td>

    < a href = "www.dotdealers.com/admin.php?dname=$domain&actedit=Edit">$domain</a>

    </td><td>$price</td></tr>";
    . . . chris

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or slightly more efficient but the same result:

    PHP Code:
    <?
    mysql_connect
    ("localhost","xxxxxx","xxxxxxx"); 
    mysql_select_db("xxxxxxxxx"); 

    $query "SELECT * FROM dd_domains"
    $result mysql_query($query); 
    ?>
    <html>
    <body bgcolor="#FFFFFF">
    <table border="0" cellspacing="0" cellpadding="4">
    <tr><td><b>domain</b></td><td><b>price</b></td></tr> 
    <? while($row mysql_fetch_array($result)) { ?>
    <tr><td><a href="www.dotdealers.com/admin.php?dname=<?=$row['name']?>&actedit=Edit"><?=$row['name']?></a></td><td><?=$row['priceb']?></td></tr>
    <? ?>
    </table>
    </body>
    </html>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PERFECT GUYS! Thanks again... this script is a HUGE time saver!

  5. #5
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey freddy,

    could you explain why your way would be more efficient? just curious.

    it just seems to me that my way might be a little easier to grasp.
    maybe it's just because of my level of experience so far.

    thanks.
    . . . chris

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I have come to the conclusion that since this is a scripting language that the more you can leave tyhe html outside the <? ?> tags the better so instead of using PHP to echo out a whole line why not just put the php where it needs to be insead of using PHP to do a bunch of stuff html can handle. This method contradicts my previous code but I am learning too, and I feel that by keeping the html outside the <? ?> whenever possible will speed things up considerably. Your way isn't wrong, I just feel that we can improve on things as we grow. right?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i hadn't looked at it from that angle, but it makes sense.
    it probably makes things easier to manage in the long run too.

    i've definitely seen my coding style improve over the past few weeks. a little more organized and efficient. growing and improving definitely, partly because of your help. i think that i've undoubtably learned more from examining code that you and others have written than by just copying and pasting. i usually try to explain things whenever i post any code, because obviously that's when the real learning happens and i appreciate it when other people do the same, rather than just saying : " here's the code, just use it "

    anyway, the point is that i get what you're saying.
    thanks again.
    . . . chris

  8. #8
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    freddy,

    Does the switching between PHP and HTML not slow down the processing? I'm just asking as being an ASP coder it's often said that switching between ASP and HTML causes the ASP processor to start and stop. Is this not the case with PHP?

    Just a curious ASP coder.

  9. #9
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting Question! I am pretty sure that the interpreter, at least while running with Apache, is a running process and doesn't need to be started and stopped each time it finds php tags
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  10. #10
    SitePoint Member
    Join Date
    Mar 2001
    Location
    Albany, NY
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When php is set up as an Apache module, it knows when to turn based on the file extension (.php, .phtml, .php3, .php4, etc). So even when you're outside of the php tags php is still running... its just looking for the next <? tag.
    John Reyes
    HostRocket.com Support

  11. #11
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    freddy!

    I have used this method for a long time because I was lazy, and didn't want to take the time to escape all of the stuff. But I have found in my large scripts lately that it does run faster with the least amount of stuff inside the <? ?> tags.

    Some people say that it is slower because the PHP engine has to start and stop, but it starts when the .php, .php3, .phtml extensions are brought up. If is just as fast as the if/else stuff... it's just a "control". So really, it's very fast, but it's just scanning OVER the html, not printing it.
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •