Hi, i’m new. ;D
Been having trouble with an in-house client management application i’ve been developing. i’m a bit new to php.
The problem is that i’ve been trying to have php POST a string value from a tag and retrieve the value from the selected using $_POST into the same page so i can perform a mysql DELETE based on that string value.
The problem is that only the first word of the string appears to be posted (eg. instead of “John Doe” only “John” is posted) and as such mysql cant find what i’m tring to delete.
Please help.
Here’s the code:
<?php include("../includes/connection.php");?>
<?php include("../includes/functions.php");?>
<?php include_once("../includes/header.php");?>
<h1>Please Select Client</h1>
<?php
if(isset($_POST['delete'])){
$client_name = $_POST['client_name'];
delete_client($client_name); /*This function deletes a row in the mysql db based on a match with the client name*/
}
?>
<form method="post" action="delete_client.php">
<?php
$client_set = get_all_clients(); /* this function performs a query to get all data from the client table */
$nr = mysql_num_rows($client_set);
?>
<select name="client_name">
<?php
for($i=0; $i<$nr; $i++){
$client_list = mysql_fetch_array($client_set);
echo "<option value=".$client_list['client_name'].">".$client_list['client_name']."</option>";
}
?>
</select><input type="submit" value="Delete" name="delete" />
</form>
<?php include("../includes/footer.php");?>