Jump to content

Recommended Posts

Hello people,

Should be easyish

 

I output a database to the user with edit and delete options for each row.

 

i decided to add two extra fields to my db one "Edit" and one "Delete" in each of them i enter the rows name. which i put on the end of a URL using "GET". Now this is the problem... If the name is "superman" it works fine but if it's "super man" i only get send "super to the next page.

 

Here's the snippit of code i use to pull the db and the GET method:

 

<?php

$query = "SELECT * FROM news";

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

	echo "<table border='1' width='465'>\n";

	echo "<tr>
	<th>Title</th>
	<th>Date</th>
	<th>Signiture</th>
	<th>News</th>
	<th>Edit</th>
	<th>Delete</th>
		  </tr>";

		$count = 0;



while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "\t<tr>\n";
foreach ($line as $col => $col_value)
{			
			if($col != "Delete" && $col != "Edit")
		echo "\t\t<td>$col_value</td>\n";	
	elseif($col == "Edit"){
	$arr = explode(" ", $col_value);
		echo "\t\t<td><center><a href=edit.php?name=$col_value>Edit</a></center></td>\n";}
	elseif($col == "Delete"){
		echo "\t\t<td><center><a href=delete.php?name=$col_value>Delete</a></center></td>\n";
	}else
		echo "\t\t<td>$col_value</td>\n";		
}
$count++;
echo "\t</tr>\n";
}

echo "</table>\n";

if ($count < 1) {

	echo "<br><br>No rows were found in this table...<br><br>";

} else {


}

?>

 

Thanks!

 

Snooble

 

Link to comment
https://forums.phpfreaks.com/topic/49350-solved-using-get-method-with-mysql/
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.