SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: I am new here

  1. #1
    SitePoint Member
    Join Date
    May 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I am new here

    and i am happy to be in ur fold.

    Please i have an issue. I am trying to make a table show all the records in a mysql table. But instead it shows only the last 2 records....

    This is the code I am using...

    Code:
    <?php do { ?>
                    <?php if($row_careers['publish']=="Y") {echo "<tr>
                      <td width=25% align=\"center\"> $row_careers[jobid] </td>
                      <td width=25% align=\"center\"> <a href=\"careersv.php?jobid=$row_careers[jobid]\" class=\"siteTextBlackA\">$row_careers[title]</a> </td>
                      <td width=25% align=\"center\"> $row_careers[newdate] </td>
                    </tr>";} ?>
                    <?php } while ($row_careers = mysql_fetch_assoc($careers)); ?>
    I would be glad to get some help

  2. #2
    SitePoint Zealot adam.jimenez's Avatar
    Join Date
    May 2009
    Location
    Ware, UK
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do more than 2 records match this criteria:

    $row_careers['publish']=="Y"

    with an uppercase Y ?

  3. #3
    SitePoint Member
    Join Date
    May 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by adam.jimenez View Post
    do more than 2 records match this criteria:

    $row_careers['publish']=="Y"

    with an uppercase Y ?
    yes, more than 2 match it, the uppercase Y is condition.

  4. #4
    SitePoint Zealot adam.jimenez's Avatar
    Join Date
    May 2009
    Location
    Ware, UK
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can we see the sql statement?

  5. #5
    SitePoint Member
    Join Date
    May 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is a simple one

    Code:
    SELECT *,date_format(postdate, '%d / %m / %Y') AS newdate
    FROM careers
    ORDER BY jobid ASC

  6. #6
    SitePoint Zealot adam.jimenez's Avatar
    Join Date
    May 2009
    Location
    Ware, UK
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bit more readable

    PHP Code:
    <?php
    while ($row_careers mysql_fetch_assoc($careers)){
        if(
    $row_careers['publish']=="Y") {
    ?>
        <tr>
              <td width=25% align="center"> <?php echo $row_careers['jobid'];?> </td>
              <td width=25% align="center"> <a href="careersv.php?jobid=<?php echo $row_careers['jobid'];?>" class="siteTextBlackA"><?php echo $row_careers['title'];?></a> </td>
              <td width=25% align="center"> <?php echo $row_careers['newdate'];?> </td>
       </tr>
    <?php
        
    }
    }
    ?>

  7. #7
    SitePoint Zealot adam.jimenez's Avatar
    Join Date
    May 2009
    Location
    Ware, UK
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by the4eyedmonk View Post
    It is a simple one

    Code:
    SELECT *,date_format(postdate, '%d / %m / %Y') AS newdate
    FROM careers
    ORDER BY jobid ASC

    why not do:
    PHP Code:
    SELECT *,date_format(postdate'%d / %m / %Y') AS newdate
    FROM careers
    WHERE publish
    ='Y'
    ORDER BY jobid ASC 
    and take the condition out of PHP

  8. #8
    SitePoint Member
    Join Date
    May 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by adam.jimenez View Post
    why not do:
    PHP Code:
    SELECT *,date_format(postdate'%d / %m / %Y') AS newdate
    FROM careers
    WHERE publish
    ='Y'
    ORDER BY jobid ASC 
    and take the condition out of PHP
    Totally makes sense...U rock!!!!
    I should begin to more with my SQL...I rely too much on PHP

    Thanks


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
  •