/    Sign up×
Community /Pin to ProfileBookmark

ok so I have a resutls page with records displayed from a search. Next to each record is an edit icon. Here is the code:

[code]
<?php
$num = trim($_POST[“num”]);
$user = addslashes(trim ($_POST[“user”]));
$start_date = trim ($_POST[“start_date”]);
$end_date = trim ($_POST[“end_date”]);
$campus = trim ($_POST[“campus”]);
$building_alfred = addslashes(trim ($_POST[“building_alfred”]));
$building_wellsville = addslashes(trim ($_POST[“building_wellsville”]));
$room = addslashes(trim ($_POST[“room”]));
$problem = trim ($_POST[“problem”]);
$summary = addslashes(trim ($_POST[“summary”]));
$description = addslashes(trim ($_POST[“description”]));
$status = trim($_POST[“status”]);
$sql_sort = trim($_POST[“sql_sort”]);
?>
<?php
echo (“<span class=’title’>Fields Searched:<br><br></span> “);
$sql = “”;

if(!empty($num)){
echo(“<span class=’title’>Work Order #: </span>”.$num.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” id LIKE ‘%$num%’ “;
}

if(!empty($user)){
echo(“<span class=’title’>Requestor: </span>”.$user.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Requestor_Name LIKE ‘%$user%’ “;
}

if(!empty($campus)){
echo(“<span class=’title’>Campus: </span>”.$campus.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Campus LIKE ‘%$campus%’ “;
}

if(!empty($building_alfred)){
echo(“<span class=’title’>Building: </span>”.$building_alfred.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Building LIKE ‘%$building_alfred%’ “;
}

if(!empty($building_wellsville)){
echo(“<span class=’title’>Building: </span>”.$building_wellsville.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Building LIKE ‘%$building_wellsville%’ “;
}

if(!empty($room)){
echo(“<span class=’title’>Room: </span>”.$room.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Room LIKE ‘%$room%’ “;
}

if(!empty($problem)){
echo(“<span class=’title’>Problem Type: </span>”.$problem.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Problem LIKE ‘%$problem%’ “;
}

if(!empty($summary)){
echo(“<span class=’title’>Summary: </span>”.$summary.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Summary LIKE ‘%$summary%’ “;
}

if(!empty($description)){
echo(“<span class=’title’>Description: </span>”.$description.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Description LIKE ‘%$description%’ “;
}

if(!empty($status)){
echo(“<span class=’title’>Status: </span>”.$status.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Status LIKE ‘%$status%’ “;
}

if(!empty($start_date)){
echo(“<span class=’title’>Start Date: </span>”.$start_date.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Date_Submitted >= STR_TO_DATE(‘$start_date’,GET_FORMAT(DATETIME,’ISO’)) “;
}

if(!empty($end_date)){
echo(“<span class=’title’>End Date: </span>”.$end_date.’&nbsp;&nbsp;&nbsp;&nbsp;’);
if (empty($sql)){
$sql = $sql.”WHERE”;
}else{
$sql = $sql.”AND”;
}
$sql = $sql.” Date_Submitted <= STR_TO_DATE(‘$end_date 23:59:59′,GET_FORMAT(DATETIME,’ISO’)) “;
}
if (!empty($sql_sort)){
$sql.= $sql_sort;
}
$sql = “SELECT * FROM workorder “.$sql.”;”;

echo (“<br>”);

?>

<?php
$link = mysql_connect(“localhost”, “webapps”, “scr1ptacc3ss”);
mysql_select_db(“helpdesk”, $link);

$results = mysql_query($sql, $link);

$num_rows = mysql_num_rows($results);

echo “<br> Records Found:n $num_rows”;

?>

<div id=”content”>
<table align=”center” class=”styled_results”>
<tr>
<th class=”clean”>Edit</th>
<th><a href=”#” onclick=”document.hidden_form.sql_sort.value='<?php
if ($sql_sort == ‘ORDER BY id DESC’){
echo ‘ORDER BY id ASC’;
}else{
echo ‘ORDER BY id DESC’;
} ?>’; document.hidden_form.submit(); return false;”>W.O.#</a></th>

<th><a href=”#” onclick=”document.hidden_form.sql_sort.value='<?php
if ($sql_sort == ‘ORDER BY Requestor_Name ASC’){
echo ‘ORDER BY Requestor_Name DESC’;
}else{
echo ‘ORDER BY Requestor_Name ASC’;
} ?>’; document.hidden_form.submit(); return false;”>Requestor</a></th>

<th><a href=”#” onclick=”document.hidden_form.sql_sort.value='<?php
if ($sql_sort == ‘ORDER BY Date_Submitted DESC’){
echo ‘ORDER BY Date_Submitted ASC’;
}else{
echo ‘ORDER BY Date_Submitted DESC’;
} ?>’; document.hidden_form.submit(); return false;”>Date Submitted</a></th>

<th><a href=”#” onclick=”document.hidden_form.sql_sort.value='<?php
if ($sql_sort ==’ORDER BY campus ASC,building ASC,room ASC’){
echo ‘ORDER BY campus DESC,building DESC,room DESC’;
}else{
echo ‘ORDER BY campus ASC,building ASC,room ASC’;
} ?>’; document.hidden_form.submit(); return false;”>Location</a></th>

<th><a href=”#” onclick=”document.hidden_form.sql_sort.value='<?php
if ($sql_sort == ‘ORDER BY problem ASC’){
echo ‘ORDER BY problem DESC’;
}else{
echo ‘ORDER BY problem ASC’;
} ?>’; document.hidden_form.submit(); return false;”>Problem Type</a></th>

<th><a href=”#” onclick=”document.hidden_form.sql_sort.value='<?php
if ($sql_sort == ‘ORDER BY summary ASC’){
echo ‘ORDER BY summary DESC’;
}else{
echo ‘ORDER BY summary ASC’;
} ?>’; document.hidden_form.submit(); return false;”>Summary</a></th>

<th><a href=”#” onclick=”document.hidden_form.sql_sort.value='<?php
if ($sql_sort == ‘ORDER BY status ASC’){
echo ‘ORDER BY status DESC’;
}else{
echo ‘ORDER BY status ASC’;
} ?>’; document.hidden_form.submit(); return false;”>Status</a></th>
</tr>
<?php
$myRow = 0;
while ($row = mysql_fetch_assoc($results)) {
$myClass = ($myRow % 2) ? “” : ” class=’odd'”;

echo ‘<tr align=”center”>’;
echo ‘<td’.$myClass.’> <img src=”../common/images/edit.gif”> </td>’;
echo ‘<td’.$myClass.’>’.$row[“id”].'</td>’;
echo ‘<td’.$myClass.’>’.$row[“Requestor_Name”].'</td>’;
echo ‘<td’.$myClass.’>’.$row[“Date_Submitted”].'</td>’;
echo ‘<td’.$myClass.’>’.$row[“Campus”].'<br>’.$row[“Building”].'<br>’.$row[“Room”];
echo ‘<td’.$myClass.’>’.$row[“Problem”].'</td>’;
echo ‘<td’.$myClass.’>’.$row[“Summary”].'</td>’;
echo ‘<td’.$myClass.’ class = “wrap”>’.$row[“Status”].'</td>’;
echo ‘</tr>’;

$myRow++;
}
mysql_free_result($results);
?>

</table>
<br>
<div align=”center”><button type=”button” onClick=”parent.location=’admin_search.php'”>Start a New Search</button></div>
</div>
<form name = “hidden_form” method=”post” action=”admin_results.php”>
<input type=”hidden” name=”num” value=”<?php echo($num) ?>” />
<input type=”hidden” name=”user” value=”<?php echo($user) ?>” />
<input type=”hidden” name=”summary” value=”<?php echo($summary) ?>” />
<input type=”hidden” name=”problem” value=”<?php echo($problem) ?>” />
<input type=”hidden” name=”campus” value=”<?php echo($campus) ?>” />
<input type=”hidden” name=”building_alfred” value=”<?php echo($building_alfred) ?>” />
<input type=”hidden” name=”building_wellsville” value=”<?php echo($building_wellsville) ?>” />
<input type=”hidden” name=”room” value=”<?php echo($room) ?>” />
<input type=”hidden” name=”description” value=”<?php echo($description) ?>” />
<input type=”hidden” name=”status” value=”<?php echo($status) ?>” />
<input type=”hidden” name=”start_date” value=”<?php echo($start_date) ?>” />
<input type=”hidden” name=”end_date” value=”<?php echo($end_date) ?>” />
<input type=”hidden” name=”sql_sort” value=”” />
</form>
[/code]

Now i need those edit icons to be links where you will be able to go to a form and see all of the information that was in the record clicked as well as editable regions for each field. Any help or guidance where to look would be awesome

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @terrigmc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...