Jump to content

[SOLVED] Using GET method with Mysql


Snooble

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

Archived

This topic is now archived and is closed to further replies.

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