trouble with some php


#1

gday guys and gals im having trouble with some code here i cant see ne thing wrong with it but maybe u’s can help me out.

Now it should just show all the results if i don’t put any search parameters in but it just keeps coming up with the error message. “There are no matching…”

thanks coolman

[php]

Comic Collectables - Search Results

Comic Collectables - Search Results

<? //Check that the form has been submitted if ($POST) { // Store form data in varibles $form_series_name = $_POST['series_name']; $form_comic_issue = $_POST['comic_issue']; $form_comic_condition = $_POST['comic_condition']; //trim the data field up $form_comic_issue = trim($form_comic_issue); //open a link to the data base $link = mysqli_connect('localhost', 'user', 'password', 'database'); //define query $query = " SELECT comics.comic_id series.series_name comics.comics_issue comics.comic_condition comics.comic_price FROM series, comics WHERE series.comic_id = comics.series_id"; //restrictions for the search if any if ($form_series_name !="") { $query .= "AND series.series_name = '$form_series_name' "; } if ($form_comic_issue !="") { $query .= "AND comics.comic_issue = '$form_comic_issue' "; } if ($form_comic_condition !="") { $query .= "AND comics.comic_condition = '$form_comic_condition' "; } // Save the results $result = mysqli_query($link, $query); //set the number of rows $number_of_rows = mysqli_num_rows($result); //close the link mysqli_close($link); } //if no records are retrieved if ($number_of_rows == 0) { echo <<<END

There are no matching records in the database. Use the Back button on your Web browser to return to the previous page and try again.

END; } else { //display the coloum headings echo <<<END

Search results are presented below

END; //Assign each row a record while ($row = mysqli_fetch_array($result)) { $comic_id = $row['comic_id']; $series_name = $row['series_name']; $comic_issue = $row['comic_issue']; $comic_condition = $row['comic_condition']; $comic_price = $row['comic_price']; //makes a new row for each record echo <<<END END; } echo "
ID Number Series Issue Condition Price
$comic_id $series_name $comic_issue $comic_condition $comic_price
"; } ?>

[/php]

**Mod edit: Added PHP tags for easier readability.


#2

Is your SQL query correct? Does your SQL server return any kind of error?