Jump to content

getting update to work


synchro_irl

Recommended Posts

hey guys

i have an admin section in my website, where i want the admin to view all the table entries of table 1 fr example, and edit the entries and click 'save' .

 

i currently have code that will display the table entries, but u cant edit them:

heres a pic of what it looks like right now:

 

searchresultsqg4.th.png

 

wat must i do to my code to allow the admin to update the table entries?

 

heres my code for this:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name       : Pluralism
Description: A two-column, fixed-width template fit for 1024x768 screen resolutions.
Version    : 1.0
Released   : 20071218

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Search4Trade</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper" style="width: 961px; height: 564px">
<div id="wrapper2">
	<div id="header">
		<div id="logo">
			<h1>search4trade.net</h1>
		</div>
		<div id="menu">
			<ul>
				<li><a href="Search1.html">Search </a></li>
				<li><a href="Login1.php">Login</a></li>
				<li><a href="#">Forum</a></li>
				<li><a href="registration.html">Register</a></li>
				<li><a href="#">About Us</a></li>
				<li><a href="#">Contact</a></li>
			</ul>
		</div>
	</div>
	<div id="page">
		<div id="content" style="width: 766px; height: 205px">
			<div class="post">
				<h2 class="title"><a href="#">Welcome to Search4Trade</a></h2>
				<div class="entry">
					<?php
$con = mysql_connect("localhost","xxx","xxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("mydatabase", $con);

$search1=$_POST["search1"];
$search2=$_POST["search2"];
$search2=$_POST["search3"];


$result = mysql_query("SELECT * FROM mytable WHERE location LIKE '%$search1%' AND type LIKE '%$search2%' AND name LIKE '%$search3%' ");



echo "<table border='1'>
<tr>
<th>Type</th>
<th>Location</th>
<th>Availability</th>
<th>StarRating</th>
<th>name</th>
<th>email</th>
<th>username</th>

</tr>";
while($row = mysql_fetch_array($result))
  {


  
echo "<tr>";
  echo "<td>" . $row['type'] . "</td>";
  echo "<td>" . $row['location'] . "</td>";
  echo "<td>" . $row['availability'] . "</td>";
  echo "<td>" . $row['StarRating'] . "</td>";

echo "<td>" . $row['name'] . "</td>";
  echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['username'] . "</td>";
  echo "</tr>";
  }


mysql_close($con);
?></div>
			</div>
		</div>
	</div>
</div>
</div>

</body>
</html>

 

EDITED BY WILDTEEN88: Removed database credentials

 

Link to comment
Share on other sites

You can add a column to your table and add a link like <a href="edit.php?id=$id>Edit</a>

 

Obviously, you need to fetch the id of each entry from your db.

 

On the edit.php page, create a form, much like the one you use to add the entries in the first place but in each input field echo the value="" as your variables. You should be able to use the same php code you used in your display of results page, only without the while statment.

 

Then have your form go to your update mysql script.

Link to comment
Share on other sites

You can add a column to your table and add a link like <a href="edit.php?id=$id>Edit</a>

 

Obviously, you need to fetch the id of each entry from your db.

 

On the edit.php page, create a form, much like the one you use to add the entries in the first place but in each input field echo the value="" as your variables. You should be able to use the same php code you used in your display of results page, only without the while statment.

 

Then have your form go to your update mysql script.

 

i understand what u mean, it will ponly disply the items in a read only table, i need it to be editable.

thanks

steve

Link to comment
Share on other sites

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.