Forum Moderators: coopster

Message Too Old, No Replies

No output from Form Query

2 options - no output - HELP!

         

omfLondon

9:41 pm on Apr 6, 2007 (gmt 0)

10+ Year Member



Why can't I get any result from dbase?

Here is form with options to choose from 2 tables in the database.

Works when I just have 1 option but when I combine the two - no output - HELP!

<form action="TCTest7.php" method="post">
<p>shopgirl
<input type="radio" value="Aerial" name="title" />
<br/>
2005
<input type="radio" value="The Devil Drive" name="title" />
</p>
<p>releaseyear
<input type="radio" value="2005" name="releaseyear" />
<br/>
<input type="submit" />
</p>

</form>

<?php
$link = mysql_connect("localhost","","");
mysql_select_db("createdb1", $link) or die("Unable to select database");

$selectSql = "SELECT * FROM music WHERE releaseyear = '".mysql_real_escape_string($_POST['releaseyear'])."'
AND title = '".mysql_real_escape_string($_POST['title'])."'";

echo $selectSql;
$result = mysql_query($selectSql, $link) or die(mysql_error());
mysql_close($link);
?>

eelixduppy

8:05 am on Apr 7, 2007 (gmt 0)



>> Why can't I get any result from dbase?

You aren't actually going through the results and printing them out.

Try something like this:


<?php
$link = mysql_connect("localhost","","");
mysql_select_db("createdb1", $link) or die("Unable to select database");
#
$selectSql = "SELECT * FROM music WHERE releaseyear = '".mysql_real_escape_string($_POST['releaseyear'])."'
AND title = '".mysql_real_escape_string($_POST['title'])."'";
#
echo $selectSql;
$result = mysql_query($selectSql, $link) or die(mysql_error());
while($row = [url=http://www.php.net/mysql-fetch-assoc]mysql_fetch_assoc[/url]($result)) {
echo '<pre>';
[url=http://www.php.net/print-r]print_r[/url]($row);
echo '</pre>';
}
mysql_close($link);
?>

A more in-depth look here: [webmasterworld.com...]

Good luck! :)

omfLondon

8:32 pm on Apr 7, 2007 (gmt 0)

10+ Year Member



THANK YOU! IT works.....! thanks so much again.