Snooble Posted April 30, 2007 Share Posted April 30, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/49350-solved-using-get-method-with-mysql/ Share on other sites More sharing options...
Psycho Posted April 30, 2007 Share Posted April 30, 2007 You need to URL encode any value son the query string. A space should be converted to '%20' (without the quotes). urlencode($value); Quote Link to comment https://forums.phpfreaks.com/topic/49350-solved-using-get-method-with-mysql/#findComment-241817 Share on other sites More sharing options...
Snooble Posted April 30, 2007 Author Share Posted April 30, 2007 spot on. Thank you ever so much. I need to buy a php book of some kind to learn all these functions! Because i go the hard way about it. I was (trying) to use explode(" ", $string); in a for each loop lol. Snooble *SOLVED* Quote Link to comment https://forums.phpfreaks.com/topic/49350-solved-using-get-method-with-mysql/#findComment-241829 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.