Hi, Im a newbie to PHP and I'm wondering if someone could help me out with this
Tryng to search out products from a database by clicking a checkbox option
for instance if description contains the word "bluetooth" and "MP3"
[code=html]
<input type="checkbox" value="bt" />Bluetooth <br />
<input type="checkbox" value="cs" />Card slot <br />
<input type="checkbox" value="mp3" />MP3 player <br />
[/code]
here is my database
[code=php]
$query = "SELECT id, manufacturer, item_number, description FROM $table_name
$result = @mysql_query ($query)
[/code]
Here is my table layout
[code=php]
echo '<table>
<tr>
<td class="layout"> <b><a href="' . $link1 . '">Manufacturer </a></b></td>
<td class="layout"> <b><a href="' . $link2 . '">Item Number</a></b></td>
<td class="layout"> <b><a href="' . $link3 . '">Descripti on</a></b></td>
</tr>
';
// Fetch and print all the records.
$bg = '#eeeeee'; // Set the background color.
while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.
echo '<tr bgcolor="' . $bg . '">
<td class="layout_n owwrap">' . $row['manufacturer'] . '</td>
<td class="layout"> ' . $row['item_number'] . '</td>
<td class="layout"> ' . $row['description'] . '</td>
</tr>
'; }
echo '</table>';
[/code]
just in case your wondering I also set cases for sorting through colums
[code=php]
$link1 = "{$_SERVER['PHP_SELF']}?sort=mfa"; // manufacturer
$link2 = "{$_SERVER['PHP_SELF']}?sort=ina"; // item_number
#and so on....
// manufacturer case
case 'mfa':
$order_by = 'manufacturer DESC, item_number DESC';
$link1 = "{$_SERVER['PHP_SELF']}?sort=mfd";
break;
case 'mfd':
$order_by = 'manufacturer ASC, item_number ASC';
$link1 = "{$_SERVER['PHP_SELF']}?sort=mfa";
break;
[/code]
hope someone can help me with this... thanks
Tryng to search out products from a database by clicking a checkbox option
for instance if description contains the word "bluetooth" and "MP3"
[code=html]
<input type="checkbox" value="bt" />Bluetooth <br />
<input type="checkbox" value="cs" />Card slot <br />
<input type="checkbox" value="mp3" />MP3 player <br />
[/code]
here is my database
[code=php]
$query = "SELECT id, manufacturer, item_number, description FROM $table_name
$result = @mysql_query ($query)
[/code]
Here is my table layout
[code=php]
echo '<table>
<tr>
<td class="layout"> <b><a href="' . $link1 . '">Manufacturer </a></b></td>
<td class="layout"> <b><a href="' . $link2 . '">Item Number</a></b></td>
<td class="layout"> <b><a href="' . $link3 . '">Descripti on</a></b></td>
</tr>
';
// Fetch and print all the records.
$bg = '#eeeeee'; // Set the background color.
while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.
echo '<tr bgcolor="' . $bg . '">
<td class="layout_n owwrap">' . $row['manufacturer'] . '</td>
<td class="layout"> ' . $row['item_number'] . '</td>
<td class="layout"> ' . $row['description'] . '</td>
</tr>
'; }
echo '</table>';
[/code]
just in case your wondering I also set cases for sorting through colums
[code=php]
$link1 = "{$_SERVER['PHP_SELF']}?sort=mfa"; // manufacturer
$link2 = "{$_SERVER['PHP_SELF']}?sort=ina"; // item_number
#and so on....
// manufacturer case
case 'mfa':
$order_by = 'manufacturer DESC, item_number DESC';
$link1 = "{$_SERVER['PHP_SELF']}?sort=mfd";
break;
case 'mfd':
$order_by = 'manufacturer ASC, item_number ASC';
$link1 = "{$_SERVER['PHP_SELF']}?sort=mfa";
break;
[/code]
hope someone can help me with this... thanks
Comment