help with php


Posted on 16th Feb 2014 07:03 pm by admin

It's not displaying or pulling anything out of the database.


Code: <html>
<head>
<title>Hale's Music World: Inventory Search Results</title>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="56%" id="table1" height="129">
<tr>
<td bgcolor="#008000" colspan"3"> </td>
</tr>
<tr>
<td colspan="3">
<p align="center"><font size="5" color="#0000FF"><b>Inventory Search Results</font></td></tr>
<tr>
<td bgcolor="#008000" colspan="3"> </td>
</tr>
<tr>
<td width="33" align="center">
<font size="4" color="#008000">
<u>Artist</u></font></td>
<td width="33%" align="center">
<font size="4" color="#008000">
<u>Title</u></font></td>
<td width="33%" align="center">
<font size="4" color="#008000">
<u>Genre</u></font></td>
</tr>

<?php

$link = mysql_connect('localhost','halesuser','hales123db');
mysql_select_db("halesmusicworld", $link);

if ( isset( $_POST['Artist_Search'] ) AND $_POST['Artist_Search'] == 1 ) {
echo '1';
$artist_search = mysql_real_escape_string( $_POST["Artist_Search"] ) . '1' ;
$query = "select * from inventory where artist like '%" . $artist_search . "%'";
$result = mysql_query( "SELECT * FROM inventory", $link );
$num_rows = mysql_num_rows( $result );
echo 'Number of matching records=' . $num_rows . '<hr>';
}

if ( isset( $_POST['Title_Search'] ) AND $_POST['Title_Search'] == 2 ) {
echo '2';
$title_search = mysql_real_espace_string( $_POST["Title_Search"] ) . '2' ;
$query = "select * from inventory where title like '%" . $title_search . "%'";
$result = mysql_query( "SELECT * FROM inventory", $link );
$num_rows = mysql_num_rows( $result );
echo 'Number of matching records='. $num_rows . '<hr>';
}

if ( isset( $_POST['Genre_Search'] ) AND $_POST['Genre_Search'] == 3 ) {
echo '3';
$genre_search=$_POST ['Genre'] ;
$query= "select * from inventory where genre like '%".$genre_search."%'";
$query_results=mysql_query($query);
$match_results=mysql_num_rows($query_results);
echo 'Number of matching records='.$match_results. '<hr>';
}
echo '</tr>';

for ($i=0; $i < $match_results; $i++)
{
echo '<tr>';
$row=mysql_fetch_array($query_results);

echo '<td align="center">', ($row ['artist'] ), '</td>';

echo '<td align="center">', ($row ['title'] ), '</td>';
echo '<td align="center">', ($row ['genre'] ), '</td> </tr>';
}

?>
<tr>
<td bgcolor="#008000" colspan="3"> </td>
</tr>
</table>
<p align="center"><i>
<a href="HalesMusicWorld_Home.html">
<font face="Arial" size="5">
Return to </font></a><font face="Arial" size="5"> <a href="HalesMusicWorld_Home.html">HalesMusicWorld Home</font></i></p>

</body>
</html>
It gives me the following error message:

[/size][/font]Notice: Undefined variable: match_results in C:wampwwwinventory_search.php on line 61

I believe it has something to do with this line of code :

for ($i=0; $i < $match_results; $i++)

No comments posted yet

Your Answer:

Login to answer
237 Like 54 Dislike
Previous forums Next forums
Other forums

Unidentified index error in a simple form
I have been trying to make an HTML form that is handled by a PHP script. So far my attempts to get i

cstdatomic (c++0x std::atomic) / g++ 4.4
Hello,

I'm trying to use cstdatomic (std::atomic in the upcoming c++0x standard) in g++

help with database debug pls
Parse error: syntax error, unexpected T_ELSE in /home/content/m/e/s/mesick/html/students/05/php/chec

mail() says sent but no email received
My code is quite simple:

Code: <?php
$to = "Ty44ler@yahoo.com";
$subje

mr8m - reverse document
Friends,

I'm trying to reverse a document held by MIRO, but it reports the message balan

Set Categories
I am creating a submission form for somebody to come in and submit products. These products are sep

a dificult string search
Hi I don't know a way around this. I want the user to input a password, but to make it a bit complca

check if string contain only a-z/A-Z
Is where any way to check if string contains only a-z/A-Z, without writing an array with all possibl

Running External Scripts
I am very new to PHP and am not even sure what I'm asking is possible. I have just installed mediaW

how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt ?
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt and so on 200-300 into file 3.txt ?

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash