Jump to content

Recommended Posts

Hi guys,

 

new here, found the site via google.

 

I've little or no PHP experience, but my website is written in PHP.

 

I would like to setup a website, were visitors can look at a list of features for a product

and put a check mark/ or an x beside the feature they would like.

Then the site would return the list of products that meets those features.

 

An example

  • x  Autoupdate feature
  • x  Help feature
  •     useless feature

 

and then say

we recommend "product alpha, as it has the following features; updater, helper, etc..."

 

Would this be asking too much?

The work would be outsourced to an online auction.

 

Link to comment
https://forums.phpfreaks.com/topic/99525-guidance-on-buying-development/
Share on other sites

Not a great problem although you'll be needing a database containing all the information about each product.

 

Have an HTML form requesting the data to search with then a query to pull the required data from the database although how you'd write the query to provide close matches I've no idea - MySQL not my real strong point here. Then all you need is a loop to display the data.

 

Depending on how much data you've got in your database depends on whether you'll be needing to look at pageinating the results.

ok...i just came up with a code in about an hour to make this happen (basic, but the main idea is still there).

 

i will post it here...

<?php
include "dbconnect.php"; //this is whatever file you use to connect to your databese.  
					  //if you dont have one you will need to write one in accordance to your host's
					  //directions (GoDaddy is different than some)
					  
if(!isset($_POST['f1']) && !isset($_POST['f2']) && !isset($_POST['f3']) && !isset($_POST['f4'])){
echo '<form name="form1" method="post" action="">
    <table width="150" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <th scope="col">Select the features that you require. </th>
      </tr>
      <tr>
        <td><p align="center">
          <input type="checkbox" name="f1" value="1">
          Feature 1</p></td>
      </tr>
      <tr>
        <td><div align="center">
          <input type="checkbox" name="f2" value="1">
          Feature 2 </div></td>
      </tr>
      <tr>
        <td><div align="center">
          <input type="checkbox" name="f3" value="1">
          Feature 3 </div></td>
      </tr>
      <tr>
        <td><div align="center">
          <input type="checkbox" name="f4" value="1">
          Feature 4 </div></td>
      </tr>
      <tr>
        <td><input type="submit" name="Submit" value="Submit"></td>
      </tr>
    </table>
  </form>';
  }
  else {

if(!isset($_POST['f1'])){
$f1='0';}
else{
$f1=1;}

if(!isset($_POST['f2'])){
$f2='0';}
else{
$f2=1;}

if(!isset($_POST['f3'])){
$f3='0';}
else{
$f3=1;}

if(!isset($_POST['f4'])){
$f4='0';}
else{
$f4=1;}


$query="SELECT * FROM features WHERE f1=$f1 AND f2=$f2 AND f3=$f3 AND f4=$f4";
$result=mysql_query($query);

$num=mysql_numrows($result);
mysql_close();


$i=0;
echo "The Product that you need is:";
while ($i < $num) {

$name=mysql_result($result,$i,"prodName");
$id=mysql_result($result,$i,"prodId");
$fe1=mysql_result($result,$i,"f1");
$fe2=mysql_result($result,$i,"f2");
$fe3=mysql_result($result,$i,"f3");
$fe4=mysql_result($result,$i,"f4");

echo "<br> $name.";

$i++;
}}

?>

 

now, i am not an experienced programmer, so anyone looking at this can tell me if i screwed anything up royally, but as i understand it, using checkboxes doesn't create a mysql security issue...if i am wrong, just tell me.

 

also, this code is being provided "as is" and you can use at your own risk...i just wanted to see if i could do it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.