Jump to content

wattsup88

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Posts posted by wattsup88

  1. [code]Oh to be specific i am using this exact code...


    $result = mysql_query("SELECT * FROM jobs ORDER BY id");

    echo "<table>";

    $_SESSION['id'] = "$id";

    $_SESSION['id'] = array();

    while ($row = mysql_fetch_array($result)) {
        $id = $row['id'];

    $_SESSION['id'][] = "$id";

        echo "<tr><td width=\"200\">$id</td>";
    echo "<td width=\"200\"><a href=\"session2.php\">View Job</a></td></tr>";
    }
    echo "</table>";
    ?>
    [/code]
  2. Is this the right idea? b/c as strange as it sounds it worked the first time but after that it gives me the same message... here's the code:

    [code]
    $result = mysql_query("SELECT * FROM jobs ORDER BY id");

    $_SESSION['id'] = "$id";
    $_SESSION['id'] = array();

    echo "<table>";

    while ($row = mysql_fetch_array($result)) {
        $id = $row['id'];
    $_SESSION['id'][] = $id;
        echo "<tr><td width=\"200\">$id</td>";
    echo "<td width=\"200\"><a href=\"session2.php\">View Job</a></td></tr>";

    }
    echo "</table>";
    ?>
    [/code]
  3. I need to know how to make a multidimensional array from $_SESSION element but for some reason php thinks it is a string... wonering if anyone has a better way to do this...

    [code]$result = mysql_query("SELECT * FROM jobs ORDER BY id");
    echo "<table>";
    while ($row = mysql_fetch_array($result)) {
        $id = $row['id'];
    $_SESSION['id'][] = $id;
    echo "<tr><td width=\"200\">$id</td>";
    echo "<td width=\"200\"><a href=\"session2.php\">View Job</a></td></tr>";
    echo "</table>";
    ?>[/code]

    Thanks
    -Jake

  4. Ok I was just wondering how to achieve this goal... I need to pass a row returned from mysql to a variable then to another page after its clicked on... I have tried two methods... The $SESSION method and the $_POST method... Both return the last value of the row and not the actual row im clicking on... Here is the code for the $_POST method

    post1.php:

    [code]
    <form name="viewjobs" action="post2.php>
    <?php
    $result = mysql_query("SELECT * FROM jobs ORDER BY id");


    //query displayed
    while ($row = mysql_fetch_array($result))
      {
        $id = $row['id'];

    print "<table border=\"1\">";
    print "<tr>";
    print "<td width=\"200\"><input type=\"hidden\" name=\"id\" value=\"$id\"><input type=\"submit\" value=\"View Job\">";
    print "<td width=\"200\">$id";
    print "</td>";
    print "</table>";

    }
    ?>
    </form>
    [/code]

    post2.php:

    [code]<?php

    echo $_POST['id'];

    ?>[/code]

    It posts the value "8" as that is the last value of the table... The next method does the same thing... However, keep in mind that I am trying to make the value of the row "clicked on" appear on the next page...Here is the $_SESSION method used...

    session1:

    [code]<a href="session2.php">Click Here</a>
    <?php
    $result = mysql_query("SELECT * FROM jobs ORDER BY id");
    //query displayed
    while ($row = mysql_fetch_array($result))
      {
        $id = $row['id'];


    print "<table border=\"1\">";
    print "<tr>";
    print "<td width=\"200\">$_SESSION['id'] = "$id";
    print "<td width=\"200\">$id";

    print "</td>";
    print "</table>";

    }
    ?>[/code]

    session2:

    [code]<?php
    echo $_SESSION['id'];
    ?>[/code]

    As i stated earlier it returns the value "8"... My best guess is that the variable is overritten every time a value from the database is returned and the last value written is the last value in the table... If anyone has a method that would be functional that would be fantistic... i know i posted something about this before but now its a little more specific so you can understand...

    Thanks in advance

    -Jake
  5. I would love to try and help you but you need to display the current code you are having problems with... and what your trying to do with it... I'm sorry arutha wasn't of much help... it did help me tho so i thought id pass that along... The code arutha puts out tho is not incorrect... at least i cant find anything wrong with it...
  6. Unfortunatly I am not familiar with the session() method :(... I do have the form tag, it is elsewhere on the page of code... I guess it needs to be right next to the other stuff??? However, i think ill try the session() method if anyone has some basic info on how to use it in my case that would be great... Oh and thanks everyone else for your help so far...
  7. hmmm... I personally don't know i dont have a high traffic rate on my site... I don't see why there would be a problem tho... Why would php be designed that way especially since so many people use $_POST superglobal to display form results and such...
  8. There is a bunch of basic knowledge that you must gain before you can just start this project... First you need to make the database that you want to pull information from... Then you have to tell your server in php of course what information to pull by making "queries"... I dont know how much you know so im starting at the beginning... There are a bunch of great tutorials out there on this matter... a few on phpfreaks.com of course but the most basic ones I've found are on this site: http://preview.arutha.co.uk/tutorials/PHP/All/1/1/... As i said earlier the first thing is making a database so do that first... I hope that gave you a direction to head in...
  9. Hello all,

    Of course im a noob or i wouldn't be asking for help so bear with me... I have been having trouble passing global variables page to page... My goal is to be able to pass an id number from one page to the next... here is the code...

    First the form code...

    //****query dispayed****//

    while ($row = mysql_fetch_array($result))
      {
            $jbc = $row['jbcategory'];
            $jbt = $row['jbtitle'];
            $jbs = $row['jbsalary'];
    $jbst = $row['jbstate'];
    $id = $row['id'];

    //alternating colors code

    $row_color = ($row_count % 2) ? $color1 : $color2;

    //alternating colors code

        print "<tr>
    <td width=\"5\" bgcolor=\"990101\" nowrap>\n";

    print "<td width=\"200\" bgcolor=\"$row_color\" no wrap>".stripslashes($jbt)."</td>";
    print "<td width=\"75\" bgcolor=\"$row_color\" no wrap>".stripslashes($jbc)."</td>";
    print "<td width=\"75\" bgcolor=\"$row_color\" no wrap>".stripslashes($jbs)."</td>";
    print "<td width=\"50\" bgcolor=\"$row_color\" no wrap>".stripslashes($jbst)."</td>";
    print "<td width=\"75\" bgcolor=\"$row_color\" no wrap><input type=\"hidden\" value=\"$id\" name=\"$id\"><input type=\"submit\" value=\"View Job\"></td>";
    print "<td width=\"5\" bgcolor=\"990101\" nowrap>\n";
        print "</tr>\n";
    $row_count++;
      }
    print "</table>\n";
    //****query dispayed****//




    Now... the result page

    <?php

    $value = $_POST['$id'];

    $result = mysql_query("SELECT * FROM jobs WHERE id = '$value'");



    //****query dispayed****//

    while ($row = mysql_fetch_array($result))

      {

            $jbc = $row['jbcategory'];
            $jbt = $row['jbtitle'];
            $jbs = $row['jbsalary'];
    $jbst = $row['jbstate'];
    $jbdesc = $row['jbdesc'];
    $jbqual = $row['jbqualifications'];
    $jbco = $row['jbcompany'];
    $jbcity = $row['jbcity'];
    $jbstatus = $row['jbstatus'];


    print "<td width=\"60\" bgcolor=\"990101\" rowspan=\"8\">\n";
    print "<tr><td><strong>Job Title: </strong><br/>".stripslashes($jbt)."</td></tr>";
    print "<tr><td><strong>Job Category: </strong><br/> ".stripslashes($jbc)."</td></tr>";
    print "<tr><td><strong>Salary: </strong><br/> ".stripslashes($jbs)."</td></tr>";
    print "<tr><td><strong>Location: </strong><br/>$jbcity, $jbst</td></tr>";
    print "<tr><td><strong>Company: </strong><br/> ".stripslashes($jbco)."</td></tr>";
    print "<tr><td><strong>Job Description: </strong><br/> ".stripslashes($jbdesc)."</td></tr>";
    print "<tr><td><strong>Job Status: </strong><br/> ".stripslashes($jbstatus)."</td></tr>";
    print "<td width=\"30\" bgcolor=\"990101\" rowspan=\"8\">\n";
        print "</tr>\n";
    $row_count++;
      }


    Thanks in advance for your help...

    -Jacob
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.