Jump to content

ririe44

Members
  • Posts

    81
  • Joined

  • Last visited

    Never

About ririe44

  • Birthday 02/15/1982

Profile Information

  • Gender
    Male

ririe44's Achievements

Member

Member (2/5)

0

Reputation

  1. Or maybe there is a way to say: if $filter_category = "Any Category" then it equals all results/everything...?
  2. K, I solved it, but I'm not totally sure what I did to fix it... I just used another one of my successful attempts and gave it a try... <td width="880"><p><div> <form method="post"> <table align="center"> <tr> <th colspan="3">Product Filter </th> </tr> <? $option_cat = mysql_query("SELECT * FROM `$tbl_name`") or die(mysql_error());?> <? $option_size = mysql_query("SELECT * FROM `$tbl_name`") or die(mysql_error());?> <tr> <td> <select name="filter_category"> <option>Select a Category!</option> <? while($row = mysql_fetch_array($option_cat)){ echo '<option value="'.$row['pd_category'].'">'.$row['pd_category'].'</option>'; } ?> </select> </td> <td> <select name="filter_size"> <option>Select a Size!</option> <? while($row2 = mysql_fetch_array($option_size)){ echo '<option value="'.$row2['pd_size'].'">'.$row2['pd_size'].'</option>'; } ?> </select></td> <td><input type=submit name="submit" value="Go!" /></td> </tr> </table> </form></p> <? if ($_POST['submit']=="Go!") { $filter_category = $_POST['filter_category']; $filter_size = $_POST['filter_size']; $filter_data = mysql_query("SELECT * FROM `$tbl_name` WHERE `pd_category` = '$filter_category' AND `pd_size` = '$filter_size'") or die(mysql_error()); Print "<table border=0 cellpadding=3 width=650 align=center>"; Print "<tr>"; Print "<th> </th> <th>Description</th> <th>Price</th> <th> </th></tr>"; while($filter_info = mysql_fetch_array( $filter_data )) { Print "<tr>"; Print "<td valign='top'>".$filter_info['pd_thumbnail'] . "</td> "; Print "<td valign='top'>".$filter_info['pd_description'] . "</td>"; Print "<td valign='top'>".$filter_info['pd_price'] . "</td>"; Print "<td valign='top'>".$filter_info['pd_btn_link'] . "</td>"; } Print "</table>"; } elseif (isset($_POST['submit'])) { die(mysql_error()); } ?> </td> So, now I would like to add an option "Any Category" and "Any Size" to my two different select tags: <select name="filter_category"> <option>Select a Category!</option> <option value="Any Category">Any Category</option> <? while($row = mysql_fetch_array($option_cat)){ echo '<option value="'.$row['pd_category'].'">'.$row['pd_category'].'</option>'; } ?> </select> </td> <td> <select name="filter_size"> <option>Select a Size!</option> <option value="Any Size">Any Size</option> <? while($row2 = mysql_fetch_array($option_size)){ echo '<option value="'.$row2['pd_size'].'">'.$row2['pd_size'].'</option>'; } ?> </select></td> So, what I'm not sure how to do... is somehow put into my code that if "Any Size" or "Any Category" were selected, then it would bring up all rows of my table as an option... $filter_category = $_POST['filter_category']; $filter_size = $_POST['filter_size']; $filter_data = mysql_query("SELECT * FROM `$tbl_name` WHERE `pd_category` = '$filter_category' AND `pd_size` = '$filter_size'") or die(mysql_error()); So... would something like this work? (well, it doesn't yet, so I need your help) <? if ($_POST['submit']=="Go!") { $filter_category = $_POST['filter_category']; $filter_size = $_POST['filter_size']; if ($filter_category == "Any Category" AND $filter_size =! "Any Size") { $filter_data = mysql_query("SELECT * FROM `$tbl_name` WHERE `pd_size` = '$filter_size'") or die(mysql_error()); } elseif ($filter_category =! "Any Category" AND $filter_size == "Any Size") { $filter_data = mysql_query("SELECT * FROM `$tbl_name` WHERE `pd_category` = '$filter_category'") or die(mysql_error()); } elseif ($filter_category =! "Any Category" AND $filter_size =! "Any Size") { $filter_data = mysql_query("SELECT * FROM `$tbl_name` WHERE `pd_category` = '$filter_category' AND `pd_size` = '$filter_size'") or die(mysql_error()); } elseif ($filter_category == "Any Category" AND $filter_size == "Any Size") { $filter_data = mysql_query("SELECT * FROM `$tbl_name` WHERE `pd_category` = '$filter_category' AND `pd_size` = '$filter_size'") or die(mysql_error()); } Print "<table border=0 cellpadding=3 width=650 align=center>"; Print "<tr>"; Print "<th> </th> <th>Description</th> <th>Price</th> <th> </th></tr>"; while($filter_info = mysql_fetch_array( $filter_data )) { Print "<tr>"; Print "<td valign='top'>".$filter_info['pd_thumbnail'] . "</td> "; Print "<td valign='top'>".$filter_info['pd_description'] . "</td>"; Print "<td valign='top'>".$filter_info['pd_price'] . "</td>"; Print "<td valign='top'>".$filter_info['pd_btn_link'] . "</td>"; } Print "</table>"; } elseif (isset($_POST['submit'])) { die(mysql_error()); } ?> Thanks!
  3. You're right... I had tried it with just `pd_category`, but I hadn't tried it with just `pd_size`, which didn't return anything. So, here's more of my code, because obviously I'm having problems getting the results from `pd_size` (however, my select box does come up with all the options from my table) <? $option_cat = mysql_query("SELECT * FROM `$tbl_name`") or die(mysql_error());?> <? $option_size = mysql_query("SELECT * FROM `$tbl_name`") or die(mysql_error());?> <td><select name="filter_category"> <option>Select a Category!</option> <? while($row=mysql_fetch_array($option_cat)){?> <option value=<?=$row['pd_category']?>><?=$row['pd_category']?></option> <? } ?> </select></td> <td><select name="filter_size"> <option>Select a Size!</option> <? while($row2=mysql_fetch_array($option_size)){?> <option value=<?=$row2['pd_size']?>><?=$row2['pd_size']?></option> <? } ?> </select></td> <td><input type=submit name="submit" value="Go!" /></td> </tr> </table> </form></p> <? if ($_POST['submit']=="Go!") { $filter_category = $_POST['filter_category']; $filter_size = $_POST['filter_size']; $pd_data = mysql_query("SELECT * FROM `$tbl_name` WHERE `pd_category` = '$filter_category' AND `pd_size` = '$filter_size'") or die(mysql_error()); Do you see where my problem is? Thanks for the help!
  4. Hey friends... I'm trying to have multiple filters effect the retrieval from my database. So, for now, I want to be able to retrieve all the rows that have the specified category AND size... $pd_data = mysql_query("SELECT * FROM `$tbl_name` WHERE `pd_category` = '$category' AND `pd_size` = '$size'") or die(mysql_error()); Right now, this is resulting in nothing... is there a better way to do this?
  5. OH YEAH!!!!! Thanks! it's working now, and I'm on my way to victory with your help! Thanks!
  6. could anybody help me with my question as stated above? I guess I'm having a hard time getting the session name equal the value from my table in the 'access' column. Any ideas?
  7. hmm... it didn't return anything... So, in my table I have a column called 'access'... shouldn't this bring up the value for the same user? $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'"; $result=mysql_query($sql); $access=$result['access'];
  8. it's still not allowing the session to register... I'm directed to my login page every time. Is there a better way to do this: session_start(); if(($_SESSION['rdz_logged'] != 'admin') && ($_SESSION['rdz_logged'] != 'pkg1') && ($_SESSION['rdz_logged'] != 'pkg2') && ($_SESSION['rdz_logged'] != 'pkg3') && ($_SESSION['rdz_logged'] != 'sales')){ header("Location: login.php"); }
  9. So, I have tried it, and it's giving me weird results. My session is registered, but it doesn't give me access like I had hoped. I'm questioning this part... does this make sense to you? $_SESSION["rdz_logged"] = $access; I've changed this code to have quotes... but still not working, any thoughts? session_start(); if(($_SESSION['rdz_logged'] != 'admin') || ($_SESSION['rdz_logged'] != 'pkg1') || ($_SESSION['rdz_logged'] != 'pkg2') || ($_SESSION['rdz_logged'] != 'pkg3') || ($_SESSION['rdz_logged'] != 'sales')){ header("Location: login.php"); }
  10. So, I took a break at this for a bit, but I'm back to solving my situation... So, I need to put together user permissions to certain pages. $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'"; $result=mysql_query($sql); $access=$result['access']; $count=mysql_num_rows($result); if($count==1){ session_start(); $_SESSION["rdz_logged"] = $access; header("location:../members.php"); } else { echo "<div align=center>The username and password you have provided are incorrect.<br>"; echo 'Return to <a href="../login.php">Login</a></div>'; } session_start(); if(($_SESSION['rdz_logged'] != admin) || ($_SESSION['rdz_logged'] != pkg1) || ($_SESSION['rdz_logged'] != pkg2) || ($_SESSION['rdz_logged'] != pkg3) || ($_SESSION['rdz_logged'] != sales)){ header("Location: login.php"); } So, do you see what I'm trying to do? Should this work?
  11. I am so confused... does anybody have an actual script that I can reference? So I can see how it's done?
  12. So, I'm obviously digging into this a bit... what about making the session name the access level... then I could allow access to pages based on the session name?
  13. Okay, I'm taking a stab at this here... play along with me (I'm very new to this)... checklogin.php $username=$_POST['username']; $password=$_POST['password']; $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'"; $result=mysql_query($sql); $access=$result['access']; if($access=='admin'){ $perms==6; }elseif($access=='sales'){ $perms==5; }elseif($access=='pkg3'){ $perms==4; }elseif($access=='pkg2'){ $perms==5; }elseif($access=='pkg1'){ $perms==2; } $count=mysql_num_rows($result); if($count==1){ session_start(); $_SESSION["logged"] = 1 + $perms; header("location:../members.php"); } else { $_SESSION["logged"] < 1 | > 7; echo "<div align=center>The username and password you have provided are incorrect.<br>"; echo 'Return to <a href="./login.html">Login</a></div>'; } So, as you can see I'm giving my user access a number level... 6 = admin, 5 = sales, etc. I want my session to equal 1 + the access level ($perms)... which I'll use for my session status to help control access to certain pages... what i'm not sure about is the else part... <1, or >7.... help?
  14. Okay, this will be basic... but at the same time I'm not really sure what to search for. I need to generate user level access controls to my site. My site will have 5 different levels: level1, level2, level3, sales, and admin. I will have 5 pages as well... level1, level2, level3, sales, and admin. The admin user will be able to see all 5 pages. The sales user will only be able to see level1 to sales. The level3 user will be able to see level1-level3... and so on. My user database will have these levels specified. Can you either help guide me towards my solution, or to another post/tutorial that could help me think through this? Thank you!
×
×
  • 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.