Jump to content

Recommended Posts

Here is my first php code:

 

<?php

$con
= mysql_connect("localhost", "username", "pass");
if (!$con)
{
die("Cannot connect: " . mysql_error());
}
mysql_select_db("dbname",$con);

if (isset ($_POST['RetrieveList'])){
$sql = "SELECT ars_no, phone_number, category_1, category_2, status, create_date, resolved_date, trouble_type_priority, ban_type FROM tbl_main";
$myData = mysql_query($sql,$con);
};

if (isset ($_POST ['delete'])){
$DeleteQuery = "DELETE from tbl_main WHERE ars_no='$_POST[ars_no]'";
mysql_query($DeleteQuery, $con);
};

echo "<table border=1>

<tr>
<th>Remedy Ticket No.</th>
<th>Phone/Incident No.</th>
<th>Category 2</th>
<th>Category 3</th>
<th>Status</th>
<th>Create Date</th>
<th>Severity</th>
<th>Ban Type</th>
<th>Resolved Date</th>
</tr>"
;

while($info = mysql_fetch_array($myData))
{
echo "<form action=smpdelete_test.php method=post>";

echo"<tr>";
echo "<td>" . "<input type=text name=ars_no disabled=disabled value=" . $info['ars_no'] . " </td>";
echo "<td>" . "<input type=text name=phone_number disabled=disabled value=" . $info['phone_number'] . " </td>";
echo "<td>" . "<input type=text name=category_1 disabled=disabled value=" . $info['category_1'] . " </td>";
echo "<td>" . "<input type=text name=category_2 disabled=disabled value=" . $info['category_2'] . " </td>";
echo "<td>" . "<input type=text name=status disabled=disabled value=" . $info['status'] . " </td>";
echo "<td>" . "<input type=text name=create_date disabled=disabled value=" . $info['create_date'] . " </td>";
echo "<td>" . "<input type=text name=trouble_type_priority disabled=disabled value=" . $info['trouble_type_priority'] . " </td>";
echo "<td>" . "<input type=text name=ban_type disabled=disabled value=" . $info['ban_type'] . " </td>";
echo "<td>" . "<input type=text name=resolved_date value=" . $info['resolved_date'] . " </td>";

echo "<td>" . "<input type=submit name=update value=update" . " </td>";

echo "<td>" . "<input type=submit name=delete value=delete" . " </td>";

 

echo "</tr>";
echo "</form>";
}
echo "</table>";

mysql_close($con);

?>

 

 

i want to integrate my first code such that when i clicked the Retrieve button in my 2nd php code the data would be printed into tables

 

<form id="form2" name="form2" method="post" action="">

<table width="741" border="1">
<tr>
<th colspan="9" scope="col" style="font-size:12px">Xid, Name:<span>
<select name="XiD" id="XiD">
<option value="Blank">Blank</option>
<option value="AAA">AAA</option>
<option value="BBB">BBB</option>
<option value="CCC">CCC</option>
<option value="DDD">DDD</option>
<option value="EEE">EEE</option>
<option value="FFF">FFF</option>
<option value="Blank">Blank</option>
</select>
</span><span style="font-size:14px">
<label for="date">Date:</label>
<input type="text" name="Date" id="Date" />
</span></th>
</tr>
<tr>
<th colspan="9" scope="col"><label for="RetrievedList"></label>
<div align="center">
<input name="RetrieveList" type="submit" id="RetrieveList" value="Retrieve List" />
<input name="DeletefromDB" type="button" id="DeletefromDB" value="Delete from DB" />
<input name="Clear" type="reset" id="Clear" value="Clear" />
</div>
<label for="DeletefromDB"></label>
<div align="center"></div>
<label for="Clear"></label>
<div align="center"></div></th>
</tr>
</table>


</form>

 

 

i want to keep the format in my 2nd php code and at the same time call the first php code after clicking the Retrieve button.

 

pls help...

 

i am stucked in those two php codes...i dont know how i can integrate these two so that when i clicked the Retrieved button on my 2nd php it will call the 1st php code.

 

btw, i also like to keep the format of my 2nd php code...so it will be like my main page then when i click the retrieved button on it...it will call the first php code to display the data in table format.

Edited by cainam29

I would like to offer some suggestions.

 

1. Never delete data, unless you are in maintenance mode.

2. If you decide to let a web (or admin) user delete data, do your deletions BEFORE pulling the data, or else you may end up displaying something that has been deleted.

 

Now as to your wants.  In order to get the second script to call the first, just enter the valid URL path to the first script, in the second scripts form action attribute:

 <form id="form2" name="form2" method="post" action="valid/path/to/second/script.php">

thanks jcbones,

 

my issue was resolved, sorry for the late confirmation.

 

but can i ask a follow up question to this...is there a way that when i click the Retrieve button on my first php it will run the query based on the selected "name" and "date" that i have chosen.

 

this is my code from 2nd php and this would act as a WHERE clause to my first php

 

<tr>
<th colspan="9" scope="col" style="font-size:12px">Xid, Name:<span>
<select name="XiD" id="XiD">
<option value="Blank">Blank</option>
<option value="AAA">AAA</option>
<option value="BBB">BBB</option>
<option value="CCC">CCC</option>
<option value="DDD">DDD</option>
<option value="EEE">EEE</option>
<option value="FFF">FFF</option>
<option value="Blank">Blank</option>
</select>
</span><span style="font-size:14px">
<label for="date">Date:</label>
<input type="text" name="Date" id="Date" />
</span></th>
</tr>

 

pls help...thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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