Jump to content

Andy Rivers

New Members
  • Posts

    7
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Andy Rivers's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. wow, thanks mac_gyver, I shall test this out and see what happens. Jacques1 is correct, the code is badly structured and I thought the pagination was having an effect on the script aswell. Thanks for your help, Andy ;-)
  2. Cool, thanks, for the reply. Example code would be great if you got the time, as I am not really sure how to go about some of that stuff. Thanks, Andy ;-)
  3. Hey eveybody, I have a single page which links to a small database with 9 records relating to cars. In the sidebar I have radio buttons with the option to filter by date (asc /desc) or by color (red, green, blue). When a radio button is selected and submitted a message is echoed to tell me which radio button was selected. The records displayed however, do nothing, they don't seem to get filtered. Here is some of the code: <?php //connect to the database $dbc = mysqli_connect('host', 'user', 'password', 'cars') or die('Error connecting to MySQL Server.'); //If RadioButton Clicked Sort the Database by dateadded Asc / Desc if(isset($_POST['submit']) && isset($_POST['dateorder']) && !empty($_POST['dateorder'])){ if($_POST['dateorder'] == 'dateasc'){ //Run query for dateasc echo "You have selected :".$_POST['dateorder']; $query = "SELECT * FROM cardetails ORDER BY caradded asc"; }elseif($_POST['dateorder'] == 'datedesc'){ //Run query for datedesc echo "You have selected :".$_POST['dateorder']; $query = "SELECT * FROM cardetails ORDER BY caradded desc"; } }else{ $query = "SELECT * FROM cardetails ORDER BY id asc"; } //If RadioButton Clicked Sort the Database by Color Red, Green, Blue if(isset($_POST['submit']) && isset($_POST['color']) && !empty($_POST['color'])){ if($_POST['color'] == 'red'){ //Run query for red color echo "You have selected :".$_POST['color']; $query = "SELECT * FROM cardetails WHERE color = 'red'"; }elseif($_POST['color'] == 'green'){ //Run query for green color echo "You have selected :".$_POST['color']; $query = "SELECT * FROM cardetails WHERE color = 'green'"; }elseif($_POST['color'] == 'blue'){ //Run query for blue color echo "You have selected :".$_POST['color']; $query = "SELECT * FROM cardetails WHERE color = 'blue'"; } }else{ $query = "SELECT * FROM cardetails ORDER BY id asc"; } $result = mysqli_query($dbc, $query) or die('Error Refreshing the page: ' . mysqli_error($dbc)); The form looks like this: <div id="leftcolumnwrap"> <div id="leftcolumn"> <h2>Trial Filters</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <p>Filter by Date:</p> <input type="radio" name="dateorder" value="dateasc"><label for="dateasc">A - Z</label><br> <input type="radio" name="dateorder" value="datedesc"><label for="datedesc">Z - A</label><br> <br><hr> <p>Filter by Colour:</p> <input type="radio" name="color" value="red"><label for="red">Red</label><br> <input type="radio" name="color" value="green"><label for="green">Green</label><br> <input type="radio" name="color" value="blue"><label for="blue">Blue</label> <br><br> <input name="submit" value="Submit" type="submit"> <br><br></form> </div> </div> Any ideas, what can I do to sort this? Thanks for any help in advance, Andy ;-)
  4. Ok thanks, I just put the spaces for ease of reading. I see now it is all to do with the declaring and initialising of the variables and if double or single quotes have been used in that part. Thanks, andy ;-)
  5. Hi all, I have the following PHP code block: <?php $website = "http://www.nationalgeographic.com"; echo 'Catch up on all the latest, visit: <a href=" ' . $website .' ">National Geographic</a>'; //works echo "<br><br>"; echo 'Catch up on all the latest, visit: <a href= ' . $website .' >National Geographic</a>'; //works echo "<br><br>"; echo 'Catch up on all the latest, visit: <a href=" . $website . ">National Geographic</a>'; // Does not work ?> Why do examples 1 and 2 only work and which is the best option to go with, if any, around the <a href="">? i.e. <a href=" ' . $website . ' "> or <a href= ' . $website . ' > or does it matter? Thanks, Andy ;-)
×
×
  • 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.