Forum Moderators: coopster
//get poetry
$get_poem = "select id, master_id, concat_ws(', ', title) as display_name from poem where master_id = $_POST[sel_id]";
$get_poem_res = mysql_query($get_poem);
if (mysql_num_rows($get_poem_res) > 0) {
$display_block .= "
<form method=\"post\" action=\"poemdisplay.php\">
<P><strong>Select a poem to view:</strong><br>
<select name=\"sel_id\" , \"sel_master_id\">
<option value=\"\" , \"\">-- Select One --</option>";
while ($recs = mysql_fetch_array($get_poem_res)){
$id = $recs['id'];
$master_id = $recs['master_id'];
$display_name = stripslashes($recs['display_name']);
$display_block .= "<option value=\"$id\" , \"$master_id\">
$display_name</option>";
}
$display_block .= "
</select>
<input type=\"hidden\" name=\"op\" value=\"view\">
<p><input type=\"submit\" name=\"submit\"
value=\"View Poem\"></p>
</FORM>";
}
This is my code to view poetry on the I-Frame:
if ($_POST[op] == "view") {
$get_poem = "select title, poem, poem_note from poem where id = $_POST[sel_id] && master_id = $_POST[sel_master_id]";
$get_poem_res = mysql_query($get_poem);
if (mysql_num_rows($get_poem_res) > 0) {
$display_block .= "<P><strong>Poem</strong><br>";
while ($add_info = mysql_fetch_array($get_poem_res)) {
$title = $add_info[title];
$poem = $add_info[poem];
$poem_note = $add_info[poem_note];
$display_block .= "<b>$title<br><br> $poem<br><br> $poem_note<br><br></b>";
}
}
}
Can anyone tell me what I am doing wrong or perhaps show me a better way to do this?
what exactly is happening? Do you get an error message?
my guess is that the html format is messed up
$display_block .= "<option value=\"$id\" , \"$master_id\">
should come out as if $id=1 and $master_id=2
<option value="1" , "2">
That isn't right, you may not have meant to escape all of those quotes, not sure.
I'm getting the following error from the poemdisplay.php I-frame.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/christia/public_html/poemdisplay.php on line 11
You can see what happens if you go to:
<snip>
And submit the poet and then title.
[edited by: engine at 7:44 am (utc) on Aug. 8, 2003]
[edit reason] No urls, thanks. See TOS [webmasterworld.com] [/edit]
$get_poem = "select id, master_id, concat_ws(', ', title) as display_name from poem where master_id = $_POST[sel_id]";
that query doesn't work, what I usually do is echo the full constructed query and then take a look at where the actual error is.
echo "<p>query:<br>",$get_poem;
put that after the line I mentioned above and then paste the query in here and we'll have a look.
that will definitely break your sql statement
I would suggest passing the two vars seperately. Once they select a writer the sel_master_id is the same for each entry. Maybe
<input type="hidden" name="sel_master_id" value="4">
when they are on the second page and
<select name="sel_id">
<option value="4"><b>In Worship</b></option>
for the drop down
$get_poem = "select title, poem, poem_note from poem where id = $_POST[sel_id] && master_id = $_POST[sel_master_id]";
I ran the query you gave me and got this reply:
query:
select title, poem, poem_note from poem where id = 1 && master_id =
error:
You have an error in your SQL syntax near '' at line 1
It seems as though I'm getting the id from the first page but not the master_id. So my problem must be in the form on the first page.