this is a code for collecting data from sql table, echoing them and sending one of the data as form data to another page for further processing
if (isset ( $price_data )) {
$price_query = "SELECT * FROM titem WHERE comment = '$price_data'";
$price_result = mysql_query ( $price_query, $connection );
if (! $price_result) {
echo 'no' . mysql_error ();
}
while ( $price_row = mysql_fetch_array ( $price_result ) ) {
$pr = $price_row['item'];
echo "<h2>" . $price_row['item'] . "</h2><br>";
echo "<input type = checkbox name = selitem value =" . $pr . "/>";
echo $selitem . "<br>";
echo $pr;
echo ' ' . 'Price = ';
if (is_numeric ( $price_row ['price'] )) {
echo $price_row ['price'] . " naira" . "<br>";
} else {
echo $price_row ['price'] . "<br>";
}
}
} else {
echo '';
}
said variable being $pr but each time i echo it in this code
<?php
echo $_POST['selitem'];
$sel = $_POST['selitem'];
echo $sel;
$query = "SELECT * FROM titem WHERE item = '$sel'";
$result = mysql_query($query, $connection);
if (isset($result)){echo 'no', mysql_error();}
while ($row = mysql_fetch_array($result))
{echo $row['comment'];}
?>
it gives me just the first word and not the complete thing when there are two or more words, hence, not allowing me to query mysql with the right values. Any help will be appreciated.