Jump to content

gb75

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gb75's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Is there a way to parse multiple variable without have loads of lines of code. The code is doing a basic select from a mysql table, then populating a table with the result of the SELECT. Each row that is retrieved will then have a link to see the entry in more detail. The code echo '<td align="center"><a href="updatetest3.php?id=' . $row['genid'] . '&tor=' . $row['TypeOfRequest'] . '&req=' . $row['RequestorName'] . '" class="button">Browse</a></td> <td align="center">' . $row['genid'] . '</td> <td align="center">' . $row['RequestorName'] . '</td> <td align="center">' . $row['DateOfRequest'] . '</td> <td align="center">' . $row['TypeOfRequest'] . '</td> <td align="center">' . $row['Country'] . '</td> <td align="center">' . $row['LedgerCode'] . '</td> What I dont really want to do is have a lots of & statements for each column in the table as the coding will just be too big.
  2. wow, now we are getting in there - this is all new for me. Can you explain and maybe provide an example of how to verify the contents of the form and the submit to the database. Thanks
  3. Thanks for your help yesterday however, I still have an issue. When coding the header("Location: crd_database.php"); after the SELECT it takes me straight to the crd_database page before the user has had a chance to update the fields from the SELECT. What I want is for the select to populate the form, then have the chance to update the form and then on the submit of the changes it updates the table again and goes off to the crd_database page. Coding the header("Location: crd_database.php"); at the end gives me an error - Warning: Cannot modify header information - headers already sent by etc etc Here is the current coding (apologies not sure how to block the code as per previous posts) $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($database,$conn) or die ("Could not open database"); if (isset($_GET['id'])) { $id = $_GET['id']; $tor = $_GET['tor']; } $query = "SELECT genid, RequestorName FROM request_detail_t WHERE genid='$id'"; //$genid = $row["genid"]; //$RequestorName =$row["RequestorName"]; header("Location: crd_database.php"); echo ' <form method="post" action="'.$_SERVER["PHP_SELF"].'" /> <table width="600" border="0" cellpadding="1"> <tr> <td width="165">Identifier:</td> <td><input name="genid" type="text" size="52" value="'.$id.'"></td> </tr> <tr> <td width="165">Requestor Name:</td> <td><input name="RequestorName" type="text" size="52" value="'.$tor.'"></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td width="100"> </td> <td><input name="update" type="submit" id="add" class="button" value="edit" ></td> </tr> </form>'; $genid= $_POST["genid"]; $RequestorName = $_POST["RequestorName"]; $update = "UPDATE request_detail_t SET genid ='$genid', RequestorName='$RequestorName' WHERE genid='$genid'"; $result = mysql_query($update) or die('Error, update query failed'); ?>
  4. Yes, I want to redirect the user to another page upon submission So basically once the update has been entered in the form, the submit button will update the database, but also at the same time it will take the users back to the database page (in this case crd_database.php)
  5. Sorry Shadiadiph, one more question - When the submit button is pressed to make the update, is there a way to point it back to the URL of the database. So - on submit go back to a URL Thanks
  6. Thanks Shadiadiph, I now have it working. Where the genid is specific was just to test, this will be a variable passed from the previous page where moved into the new page.
  7. Hi Shadiadiph & Lonewolf217 Thanks for the quick responses - Yes, the form is used to pull information from the database, then I update the information and submit it back into the database. I have tried to adapt the piece of code Shadiadiph posted but the 1st SELECT retrieves a blank (there is an entry in the table ) I have posted the updated code below $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($database,$conn) or die ("Could not open database"); $action= $_GET["action"]; if($action=="") { $action = "add"; } if ($action=="update") { $query = "SELECT genid, requestorname FROM request_detail_t WHERE genid='16'"; $genid = $row["genid"]; $RequestorName =$row["RequestorName"]; } echo ' <form method="post"> <table width="600" border="0" cellpadding="1"> <tr> <td width="165">Identifier:</td> <td><input name="genid" type="text" size="52" value="' . $row['genid'] . '"></td> </tr> <tr> <td width="165">Requestor Name:</td> <td><input name="RequestorName" type="text" size="52" value="' . $row['RequestorName'] . '"></td> </tr> <tr> <td><input name="edit" type="submit" id="add" class="button" value="edit"></td> </tr> </form>'; $action= $_POST["action"]; $genid= $_POST["genid"]; $RequestorName = $_POST["RequestorName"]; if ($action=="update") { $query = "UPDATE request_detail_t SET genid ='$genid', RequestorName='$RequestorName' WHERE genid='$genid'"; } ?>
  8. Hi I'm a newbie to php and mysql and i'm having trouble with a query. Here's the issue First of all I have a form which when completed updates a table. Then I have a database page which first runs a SELECT query to retrieve the results of the form... What I need to do is then have the ability to update the retrieved form but this time I need to have an UPDATE query embedded into the code to update the table. So therefore a SELECT and UPDATE query in the same piece of code. Any help greatly appreciated.....Gary
×
×
  • 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.