Jump to content

Please Help with Retrieving information automatically


Gatedmk4

Recommended Posts

Hi all Hoping you can help as ive been stuck for a few days. just to keep in mind ive only been learning php for bout 3 weeks so my scripting is going to be all over the place and probably be alot of things that could have been written better but im just looking for functionality at the moment. constructive criticism is fine by me. heres my story.

 

I am currently building a php website for my company to make the paperwork a hell of alot less. which involves making our job sheets into electronic job sheets but i have run into a bit of a problem.

 

here i have all the jobs that are in progress listed.

 

    $result = mysql_query("SELECT * FROM job WHERE complete='N' ORDER BY jobnumber ASC")

 

    or die(mysql_error());

 

    $link = 'progressasc.php';

 

    echo "<table border='1'>";

    echo "<tr> <th><a href='".$link."'>Date</a></th> <th><a href='".$link."'>Job Number</a></th> <th><a href='".$link."'>Description</a></th> <th><a href='".$link."'>Customer</a></th> <th><a href='".$link."'>Contact Name</a></th> <th><a href='".$link."'>Responsible</a></th></tr>";

 

    while($row = mysql_fetch_array( $result )) {

 

    $link = 'details.php?jobnumber=' . $row['jobnumber'];          <---        //point of interest here.

    echo "<tr><td>";

    echo $row['date'];

    echo "</td><td>";

    //echo $row['jobnumber'];

    echo "<a href='".$link."'>".$row['jobnumber']."</a>";

    echo "</td><td>";

    echo $row['requirements'];

    echo "</td><td>";

    echo $row['customer'];

    echo "</td><td>";

    echo $row['contactname'];

    echo "</td><td>";

    echo $row['responsible'];

    echo "</td></tr>";

 

}

echo "</table>";

 

ok so with the $link it sends me to details.php?jobnumber=3306 of course the last 3 digits are going to keep changing.

 

so my problem is this, i need to be able to click on the job number and have it retrieve all the information out of the database inregard to that unique jobnumber clicked. the only way i thought i would be able to do it is to parse the url or something of that sort then extract the jobnumber out of the url once its parsed. i have tried many different ways of doing it and none of them seem to work its getting rather annoying but i am determined to make this work.

 

here is my details.php

 

<?php

if (isset($_REQUEST['Submit'])) {

$sql = "UPDATE job SET        customer='".mysql_real_escape_string(stripslashes($_REQUEST['Customer']))."',            requirements='".mysql_real_escape_string(stripslashes($_REQUEST['Requirements']))."',

                            date='".mysql_real_escape_string(stripslashes($_REQUEST['Date']))."',                    contactname='".mysql_real_escape_string(stripslashes($_REQUEST['ContactName']))."',

                            phnumber='".mysql_real_escape_string(stripslashes($_REQUEST['PhoneNumber']))."',        ordernumber='".mysql_real_escape_string(stripslashes($_REQUEST['OrderNumber']))."',

                            daterequired='".mysql_real_escape_string(stripslashes($_REQUEST['DateRequired']))."',  parts='".mysql_real_escape_string(stripslashes($_REQUEST['Parts']))."',

                            details='".mysql_real_escape_string(stripslashes($_REQUEST['Details']))."',                start1='".mysql_real_escape_string(stripslashes($_REQUEST['Start1']))."',

                            start2='".mysql_real_escape_string(stripslashes($_REQUEST['Start2']))."',                start3='".mysql_real_escape_string(stripslashes($_REQUEST['Start3']))."',

                            start4='".mysql_real_escape_string(stripslashes($_REQUEST['Start4']))."',                end1='".mysql_real_escape_string(stripslashes($_REQUEST['End1']))."',

                            end2='".mysql_real_escape_string(stripslashes($_REQUEST['End2']))."',                      end3='".mysql_real_escape_string(stripslashes($_REQUEST['End3']))."',

                            end4='".mysql_real_escape_string(stripslashes($_REQUEST['End4']))."',                      total1='".mysql_real_escape_string(stripslashes($_REQUEST['Total1']))."',

                            total2='".mysql_real_escape_string(stripslashes($_REQUEST['Total2']))."',                total3='".mysql_real_escape_string(stripslashes($_REQUEST['Total3']))."',

                            total4='".mysql_real_escape_string(stripslashes($_REQUEST['Total4']))."',                complete='".mysql_real_escape_string(stripslashes($_REQUEST['complete']))."',

                            responsible='".mysql_real_escape_string(stripslashes($_REQUEST['mydropdown']))."',

                            type='".mysql_real_escape_string(stripslashes($_REQUEST['type']))."'

 

                            WHERE jobnumber='".mysql_real_escape_string(stripslashes($_REQUEST['Jobnumber']))."'";

 

 

        if($result = mysql_query($sql)) {

    echo '<h3>Success!</h3>';

} else {

    echo "ERROR: ".mysql_error();

}

} else {

 

?>

 

above is the exact code for my update.php. all i need is more php script above this, to have the details.php automatically extract the information from the database when jobnumber is clicked.

 

any help would be greatly appreciated.

 

Cheers

To select the details of the job based on the url produced in your first code block...

 

if(isset($_GET['jobnumber'] && is_numeric($_GET['jobnumber'])) {
   $sql = "SELECT * FROM jobs WHERE jobnumber={$_GET['jobnumber']} LIMIT 1";
   $result = mysql_query($sql);
   $details = mysql_fetch_assoc($result);
}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.