SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Following Kevin's excellent Building a Database Driven Website article,

    http://www.webmasterbase.com/article.php/228/668

    I am building a database driven "Help Wanted" page. I am using a table similar to the one on page 60.

    It works fine (almost), except when I try to include the table in my site's template. It does not seem to respect the width attributes of my surrounding tables:

    [URL=http://http://www.kripalushop.org/kripalu/kripaluonline/human_resources/open_jobs/open_jobs_list.php3 ].

    I have tried manipulating the tables with pixel and % attributes, but nothing seems to help. Any ideas?

    Also, the above "almost" refers to the message

    Warning: 1 is not a MySQL result index in /home/kripalu/website/kripalu/kripaluonline/human_resources/open_jobs/open_jobs_list.php3 on line 129.
    I have looked at line 129 and have puzzled over this for some time. Any ideas?
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well it appears your result table is 466 pixels wide:

    Code:
     
    <TABLE WIDTH="466" BORDER=1>
    Is that not the desired width, if it is I noticed you haven't assigned the cells in the table to any width and also none of the surrounding cells have width attributes.

    AS for your second problem, you will need to show us what line the error refers to, not just a line number but the actual code, it would be even better if showed us several lines before and after the error line as well, for we can not tell what your code looks like from here, just post it and I am sure someone can tell you whats wrong.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Table width control in content display

    I set the left navbar to 140 pixels and the PHP table to 466 so that together they would amount to no more than 606, which is the width of my template. I think it may be the error message that is driving the left margin out too far on page http://www.kripalushop.org/kripalu/k...jobs_list.php3

    There is the block of PHP code that the error message refers to on line 129 this page - line 129 refers to the "while" line
    PHP Code:
    <?php
    $jobs 
    mysql_query($select $from $where);
    if (!
    $jobs) {
      echo(
    "</TABLE>");
      echo(
    "<P>Error retrieving content from database!<BR>".
           
    "Error: " mysql_error());
      exit();
    }

    while (
    $jobs mysql_fetch_array($jobs)) {
      echo(
    "<TR>\n");
      
    $id       $jobs["OJID"];
      
    $jobtext $jobs["OJText"];
      echo(
    "<TD>$jobtext</TD>\n");
      echo(
    "<TD>[<A HREF='editjob.php?id=$id'>Edit</A>|".
           
    "<A HREF='deletejob.php?id=$id'>Delete</A>]</TD>\n");
      echo(
    "</TR>\n");
    }
    ?>
    I am having the same problem with page http://www.kripalushop.org/kripalu/k..._open_job.php3 where the error refers to line 151, which is the endif; statement in this block of code

    PHP Code:
    <!-- Form for adding job -->

    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
    <P>Enter the new job:<BR>
    <TEXTAREA NAME="jobtext" ROWS=15 COLS=45 WRAP>
    </TEXTAREA>

    <P><INPUT TYPE=SUBMIT NAME="submitjob" VALUE="SUBMIT"></P>
    </FORM>

    <!-- End form for adding job -->

    <?php
    //Insert Query
    if ("SUBMIT" ==$submitjob) {
      
    $sql "INSERT INTO OpenJobs SET " .
             
    "OJText='$jobtext', " .
             
    "OJID='$ojid'";
      if (
    mysql_query($sql)) {
        echo(
    "<P>New job added.</P>");
      } 
      
      else {
        echo(
    "<P>Error adding new job. " .
             
    mysql_error() . "</P>");
        exit();
      }
     }

     
    //When clicked, this link will load this page
     //with the job submission form displayed.
     
    echo("<P><A HREF='$PHP_SELF'>Add another job.</A></P>");
        

    endif;

    ?>
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Two things, don't use the same variable name in your while() loop as you use for your mysql_query() in your case $job is used for both things, so change one of them like this

    PHP Code:
    <?php
    $result 
    mysql_query($select $from $where);
    if (!
    $result) {
      echo(
    "</TABLE>");
      echo(
    "<P>Error retrieving content from database!<BR>".
           
    "Error: " mysql_error());
      exit();
    }

    while (
    $jobs mysql_fetch_array($result)) {
      echo(
    "<TR>\n");
      
    $id       $jobs["OJID"];
      
    $jobtext $jobs["OJText"];
      echo(
    "<TD>$jobtext</TD>\n");
      echo(
    "<TD>[<A HREF='editjob.php?id=$id'>Edit</A>|".
           
    "<A HREF='deletejob.php?id=$id'>Delete</A>]</TD>\n");
      echo(
    "</TR>\n");
    }
    ?>

    The other it would appear that you don't even need the endif; since you don't have a if(): in there, you are using curly brackets if() { } so you don't need the endif;
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Table width control in content display

    Many thanks for your helpful suggestions. They worked fine. Now I am on to new challenges in the same project, but I will start a new thread as it was the error messages that was causing the table width problems.
    Paul C.
    ClickBasics
    http://www.clickbasics.com


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
  •