passing data re: POST ( I read the sticky!)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
knight
Forum Newbie
Posts: 5
Joined: Tue Feb 25, 2003 5:34 pm
Location: B.C.

passing data re: POST ( I read the sticky!)

Post by knight »

I'm new at this. I want to have a user choose from a displayed list & pass
the choice to another page. I've tried session variables, $_POST. I can send the displayed array pointer I want (requestoption), but not the data in
the chosen row9identbook[]). Thanks for your patience:)

for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
$identbook[]=$row["bookid"];
echo "<p><strong>".($i+1).". Title: ";
echo stripslashes($row["title"]);
echo "</strong><br>Author: ";
echo stripslashes($row["author"]);
echo "<br>Genre: ";
echo $row["genre"];
echo " &nbsp;&nbsp; Format: ";
echo $row["format"];
echo " &nbsp;&nbsp; Condition: ";
echo $row["condition"];

}
echo "</p>";
}
?>

<form action="confirmation.php" method="post" >
<font face="Arial, Helvetica, sans-serif"><strong>Request
Option #:</strong></font>
<input type="hidden" name="identbook[]">
<input type="text" name="requestoption" maxlength=4 size=4>
<input type=submit name="Confirm" value="Confirm">
</form>
hurkle
Forum Newbie
Posts: 15
Joined: Tue Feb 11, 2003 1:21 pm
Location: Minnesota, USA

Post by hurkle »

I would suggest something like this..

Code: Select all

for ($i=0; $i <$num_results; $i++) 
&#123; 
$row = mysql_fetch_array($result); 

echo "<A href = 'confirmation.php?identbook=";

echo $row&#1111;"bookid"] . "'>";


 
echo "<p><strong>".($i+1).". Title: "; 
echo stripslashes($row&#1111;"title"]); 
echo "</strong></A><br>";
echo "Author: "; 
echo stripslashes($row&#1111;"author"]); 
echo "<br>Genre: "; 
echo $row&#1111;"genre"]; 
echo "    Format: "; 
echo $row&#1111;"format"]; 
echo "    Condition: "; 
echo $row&#1111;"condition"]; 

&#125;
This is just one way of doing it. Each row in your result generates a link. The meat of the link is the processing script, and the book ID number, all the rest is display. Of cource, your target script needs to be able to handle info coming at in in GET rather than POST.

You could also use checkboxes or radiobuttons. Each one gets the same name, but the appropriate id value. I think radiobuttons limit to one selected, but you'd want to check. Then, I think only the selected one will get POST'ed to your script.

I hope that helps, and maybe makes sense..
knight
Forum Newbie
Posts: 5
Joined: Tue Feb 25, 2003 5:34 pm
Location: B.C.

I'll try that

Post by knight »

thanks, Hurkle. That's an approach I never thought of.
Post Reply