Jump to content

Recommended Posts

Hello ,

 

hOPE ANYONE CAN HELP ME FOR THIS..

 

<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "admin") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM form_info")
or die(mysql_error());  

echo "<table border='1'>";
echo "<tr><th>Id Nor:</th> <th>First Name:</th> <th>Last Name:</th> <th>Email:</th> <th>Birthday:</th> <th>Gender:</th> <th>Address:</th> <th>Phone</th> <th>Mobile</th> <th>Fax</th></tr>";
// store the record of the "form_info" table into $row
while($row = mysql_fetch_array($result)){

// Print out the contents of the entry 
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>"; 
echo $row['id_nor'];
echo "</td><td>"; 
echo $row['FirstName'];
echo "</td><td>"; 
echo $row['LastName'];
echo "</td><td>"; 
echo $row['Email'];
echo "</td><td>"; 
echo $row['Birthday'];
echo "</td><td>"; 
echo $row['Gender'];
echo "</td><td>"; 
echo $row['Address'];
echo "</td><td>"; 
echo $row['Phone'];
echo "</td><td>"; 
echo $row['Mobile'];
echo "</td><td>"; 
echo $row['Fax'];
echo "</td></tr>"; 
} 

echo "</table>";
?>

 

-----------------

i DONT KNOW WHERE IM WRONG SO IF ANYONE CAN GET ME SM IDEA WOULD BE APPRICIATED!!

 

rEGARDS,

NJ

 

 

Link to comment
https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/
Share on other sites

I got the issue.I was using two while loops so thats the reason ..

Thanks for all to give me suggestion .

 

If anyone can give me sm idea about how to place edit and delete features in this table..

Hope you all get wht i mean.

----------------

Regards,

Nj

 

echo "<a href='edit.php?$row[id_nor]'>Edit</a>";

Any row u can pick from ur table,Id is mostly effecaint .

 

echo "<a href='delete.php?$row[id_nor]'>Delete</a>";

 

U can make edit.php and delete.php pages OR can make just one page and Pass there action like:

 

echo "<a href='edit_delete.php?$row[id_nor]&action=delete'>Delete</a>";

 

echo "<a href='edit_delete.php?$row[id_nor]&action=edit'>Edit</a>";

Now just make one script edit_delete.php and Use GET to get the values from the 1st page.

 

Hope it will help.

 

echo "<a href='edit.php?$row[id_nor]'>Edit</a>";

Any row u can pick from ur table,Id is mostly effecaint .

 

echo "<a href='delete.php?$row[id_nor]'>Delete</a>";

 

U can make edit.php and delete.php pages OR can make just one page and Pass there action like:

 

echo "<a href='edit_delete.php?$row[id_nor]&action=delete'>Delete</a>";

 

echo "<a href='edit_delete.php?$row[id_nor]&action=edit'>Edit</a>";

Now just make one script edit_delete.php and Use GET to get the values from the 1st page.

 

Hope it will help.

 

 

Hello mmarif4u,

Thanks for reply!!

That code is working but u wrote tht to make any edit page and use GET to get the values

But im not able to do so if you can give me more idea on this would be gr8 to me:)

 

Regards,

Nj

Sorry i forgot to add id in url.

echo "<a href='edit.php?id=$row[id_nor]'>Edit</a>";

 

Lets take example.

It will take every record with id and in the another page you can use GET to get the value.

like:

$id=trim($_GET['id']);

 

And do the rest of coding using where clause in query like:

 

$sql="select * from table where id='$id'";

 

Show the data or you can also amend it there.

 

Just to make some further coding.

 

 

DELETE - this is from my code you will have to change it.

 

 

<?php

// Include the PHP script that contains the session information.

include('../includes/session_admin.php');



// Get the user id from the URL.

$bid = $_GET['bid'];



// Connect to the database.

require_once ('../../../datemysql_connect.php');



// Set up the query.

$query = "DELETE FROM listing WHERE b_id=$bid";



// Run the query.

$results = @mysql_query ($query);



// Reload the page.

$url = '../b_review.php';

header("Location: $url");



?>

 

 

EDIT... again from my code

 

/ Get the article id from the URL.
	$bid = $_GET['bid'];

	// Start and run the query.
	$query = "SELECT bname, address, city, state, zip, phone, phone2, fax, website, email, discription, activities, photo, directions, link, map, hours FROM listing WHERE b_id=$bid";
	$results = @mysql_query($query);

	if ($results)
	{
		$row = mysql_fetch_array($results, MYSQL_ASSOC);

		// Save the results into variables.
		$bname = $row['bname'];
		$address = $row['address'];
		$city = $row['city'];
		$state = $row['state'];
		$zip = $row['zip'];
		$phone = $row['phone'];
		$phone2 = $row['phone2'];
		$fax = $row['fax'];
		$website = $row['website'];
		$email = $row['email'];
		$discription = $row['discription'];
		$activities = $row['activities'];
		$photo = $row['photo'];
		$directions = $row['directions'];
		$map = $row['map'];
		$hours = $row['hours'];
		$link = $row['link'];
	}
	else
		echo 'An error occured.';
	?>

<div id="content">
		<div class="innerContent">
			<form name="EditDate" action="b_edit.php" method="post">
				<table align="center" width="100%" border="0" cellpadding="1" cellspacing="0">
				<tr>
					<td class="title" colspan="2">Edit Business Listing</td>
				</tr>
				<tr>
					<td>Name:</td>
					<td><input type="text" class="required" name="bname" id="focus" size="40" value="<?php echo $bname; ?>" maxlength="40"></td>
				</tr>
				<tr>
					<td>Address:</td>
					<td><input type="text" class="required" name="address" size="40" value="<?php echo $address; ?>" maxlength="40"></td>
				</tr>

BLAH BLAH BLAH


The best trick here is to make one script.

And no need to pass three variables in the link,just ID is enough and surely it will be unique.

Just pass the Id in the url with action or something like that and use if statement there like:

if(action==edit){

$id=trim($_GET['id'];

do edit part

}

 

if(action==delete){

$id=trim($_GET['id'];

do delete part

}

 

And use update command in edit area to do updating.

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.