Jump to content

ratcateme

Members
  • Posts

    1,216
  • Joined

  • Last visited

    Never

Everything posted by ratcateme

  1. well im not sure exactly how you have made your database. but you could make it like the following: Shelters( `ID` INT(11) `name` VARCHAR(50) ) Breeds( `ID` INT(11) `name` VARCHAR(50) ) Dogs( `ID` INT(11) `breed_id` INT(11) `shelters_id` INT(11) `male` INT(1) `child` INT(1) `other_dogs` INT(1) ) (dont think that is valid mysql) then your form could be generated like <?php include "dbConnect.php"; $result = mysql_query("SELECT * FROM `Shelters`"); while($row = mysql_fetch_assoc($result)){ echo "<input type=\"checkbox\" name=\"shelters[]\" id=\"shelter_{$row['ID']}\" value=\"{$row['ID']}\" /><label for=\"shelter_{$row['ID']}\">{$row['name']}</label><br/>"; } $result = mysql_query("SELECT * FROM `Breeds`"); while($row = mysql_fetch_assoc($result)){ echo "<input type=\"checkbox\" name=\"breeds[]\" id=\"breed_{$row['ID']}\" value=\"{$row['ID']}\" /><label for=\"breed_{$row['ID']}\">{$row['name']}</label><br/>"; } ?> <h2 class="title">Gender</h2> <p class="sub">Indicate if you would prefer a male of female</p> <label for="male">Male</label> <label for="female"> <input type="radio" name="sex" id="male" value="Male" /> Female <input type="radio" name="sex" id="female" value="Female" /> </label> <label for="both">Don't Mind</label> <input name="sex" type="radio" id="both" value="both" checked="checked" /> <h2 class="title">Child Friendly?</h2> <p class="sub">Will your dog be living around young children?</p> <input name="child" type="radio" id="yes" value="Yes" checked="checked" /> <label for="yes">Yes</label> <input type="radio" name="child" id="no" value="No" /> <label for="no">No</label> <h2 class="title">Living with other dogs?</h2> <p class="sub">Will your dog be living with any other dogs?</p> <input name="dogs" type="radio" id="yes" value="Yes" checked="checked" /> <label for="yes">Yes</label> <input type="radio" name="dogs" id="no" value="No" /> <label for="no">No</label> <p> <input type="submit" name="submit" id="submit" value="Submit" /> <?php if(isset($_POST['shelters'])){ $breeds_where = ""; if(isset($_POST['breeds'])){ foreach($_POST['breeds'] as $breed){ $breed = mysql_real_escape_string($breed); if($breeds_where != ""){ $breeds_where .= " OR "; } $breeds_where .= "`breed_id` = $breed"; } } $common_where = ""; if($_POST['sex'] == "male"){ if($common_where != ""){ $common_where .= " AND "; } $common_where = "`male` = 1"; }elseif($_POST['sex'] == "female"){ if($common_where != ""){ $common_where .= " AND "; } $common_where = "`male` = 0"; } if($_POST['child'] == "yes"){ if($common_where != ""){ $common_where .= " AND "; } $common_where = "`child` = 1"; } if($_POST['dogs'] == "yes"){ if($common_where != ""){ $common_where .= " AND "; } $common_where = "`other_dogs` = 1"; }elseif($_POST['dogs'] == "no"){ if($common_where != ""){ $common_where .= " AND "; } $common_where = "`other_dogs` = 0"; } if($breeds_where != ""){ if($common_where != ""){ $common_where .= " AND "; } $common_where .= "($breeds_where)"; } foreach($_POST['shelters'] as $shelter){ echo "<h2>$shelter</h2><br />"; $shelter = mysql_real_escape_string($shelter); $query = "SELECT * FROM `Dogs` WHERE `shelter_id` = $shelter AND $common_where"; $result = mysql_query($query) or die(mysql_error() . "<br>" . $query); if(mysql_num_rows($result) == 0){ echo "No matching dogs<br />"; continue; } while($row = mysql_fetch_assoc($result)){ $breed = mysql_result(mydsql_query("SELECT `name` FROM `Breeds` WHERE `ID` = {$row['ID']}")or die(mysql_error()),0); echo "<h3>$breed </h3><br/>"; echo ($row['male'] == 1?"Male":"Female"). "<br />"; echo ($row['child'] == 1?"Good For Children":"Not so good with Children"). "<br />"; echo ($row['other_dogs'] == 1?"Good with other dogs":"Not so good with other dogs"). "<br />"; } } } ?> i was board lol think it should work but you need to make some admin scripts and stuff
  2. someone was having this problem just a couple pf days ago when you add a rewrite like this the URLs change so where you had a image URL "images/top.gif" the browser turns it into "http://www.mysite.com/images/top.gif" so when you have a page at "http://www.mysite.com/countrydetails/2" the image URL is at "http://www.mysite.com/countrydetails/2/images/top.gif" to fix this you need to add a "/" to the front of the URL so you image and css links should look like this "/images/top.gif" that way when the page is at "http://www.mysite.com/countrydetails/2" it loads "http://www.mysite.com/images/top.gif" this also applies to all your links and ajax calls Scott.
  3. what exactly are you trying to achive i put this code in test.php <?php if(strpos($_SERVER['REQUEST_URI'],"?")!== false){ echo "you put a ? in the URL "; exit; } echo "you are ok"; and then went to /test.php and got "you are ok" then went to /test.php? and got "you put a ? in the URL " isn't that what you want? Scott.
  4. sorry i meant $_SERVER['REQUEST_URI'] if(strpos($_SERVER['REQUEST_URI'],"?")!== false){ echo "you put a ? in the URL "; exit; } Scott.
  5. if(strpos($_SERVER,"?")!== false){ echo "you put a ? in the URL "; exit; } that what you want?? Scott.
  6. here is a basic search with very basic stuff and should be protected ageist all SQL injections <?php include "dbConnect.php"; if(isset($_GET['search'])){ $search = mysql_real_escape_string($_GET['search']); $query = "SELECT * FROM `table` WHERE `name` LIKE(\"%$search%\") OR `name_2` LIKE(\"%$search%\")"; $result = mysql_query($query) or die(mysql_error() . "<br>" . $query); if(mysql_num_rows($result) == 0){ echo "No results returned"; }else{ echo "<table>"; while($row = mysql_fetch_assoc($result)){ echo "<tr><td>{$row['id']}</td><td>{$row['value']}</td><td>{$row['pic_url']}</td></tr>"; } echo "</table>"; } } ?> <form method=get> <input type="text" name="search" value="<?=$_GET['search']?>" /><input type="submit" value="Search" /> </form> it would proberly need some work but it shows a basic search function
  7. have a look at this pear package http://pear.php.net/package/Mail_Mime it is well documented and has support for adding attachments Scott.
  8. check out this thread for more details but you are looking at mod_rewrite http://www.phpfreaks.com/forums/index.php/topic,126435.0.html basically you want this in a .htaccess file RewriteEngine on RewriteRule ^ countrydetails/([^/\.]+)/([^/\.]+)$ countrydetails.php?$1&status=$2 [L] putting that in a .htaccess file everytime a url like countrydetails/srilanka/1 is called php $_GET gets filled in so the server sees countrydetails.php?srilanka&status=1 Scott.
  9. can you do mysql queries? if not read up on how to do and display a mysql query here http://www.tizag.com/ now for the search you can use a query like $query = "SELECT * FROM `table` WHERE `name` LIKE(\"%$search%\") OR `name_2` LIKE(\"%$search%\")"; Scott.
  10. for <a href=” countrydetails.php?countryid=20&status=1”> srilanka</a> you could use $_GET['countryid'] and $_GET['status']; Scott.
  11. really most people developing in php are only using hosts with PHP5 as PHP4 is outdated and support for it has discontinued Scott.
  12. what do you mean do you not want to pass the countryid in the url? you can use $_POST or $_SESSION but it sounds like $_GET is the best way Scott.
  13. sorry silly me didn't see that umm try adding AddHandler php5-script .xml and dont use the AddType directive to your htaccess file also you should be able to find all the info you need in /etc/httpd/conf.d/php.conf on linux im not sure of the windows path Scott.
  14. did you have a look at the source of the link <? header('Content-type: text/xml'); ?> <rss version="2.0"> <channel> <title>SecondCitySaint.com</title> <description>It's About Me</description> <link>http://secondcitysaint.com/</link> <copyright>All material copyright 2004-2009 Mike Maloney</copyright> <item> <title> <![CDATA[ <?php echo "Hi."; ?> ]]> </title> <description> <![CDATA[ <?php echo "Hello again"; ?> ]]> </description> <link>http://secondcitysaint.com/index.php?id=<?php echo "243"; ?></link> </item> </channel> </rss> your server doesn't have short tags enabled (<?) try adding <?php to the start or updating you php.ini to allow short tags Scott.
  15. echo strlen($username) > 11? substr($username,0,."...": $username; and it can be used inline like echo "<div>" . (strlen($username) > 11? substr($username,0,."...": $username) . "</div>"; the brackets are not needed but make it easier to read Scott.
  16. yea thats it umm $this->conn->query($q) or die($this->conn->error); //<--------THE ERROR IS HERE should be $result = $this->conn->query($q) or die($this->conn->error); //<--------THE ERROR IS HERE also to avoid errors i add a check to see if the query returned any rows function get_First_Name($un, $pwd) { $q = "SELECT firstname FROM users WHERE username = '$un' AND password = '$pwd' LIMIT 1"; $result = $this->conn->query($q) or die($this->conn->error); if($result->num_rows == 1){ $row = $result->fetch_assoc(); $_SESSION['userfirstname'] = $row['firstname']; } $this->conn->close(); } Scott.
  17. try $this->conn->query($q) or die($this->conn->error); //<--------THE ERROR IS HERE for the query line i must say i am not very fimilar with mysqli i know it is better than mysql but i think for getting the result $row = $result->fetch_assoc(); $_SESSION['userfirstname'] = $row['firstname']; should do it Scott.
  18. you are using the mysqli class but passing the class to mysql which is like very wrong try function get_First_Name($un, $pwd) { $q = "SELECT firstname FROM users WHERE username = '$un' AND password = '$pwd' LIMIT 1"; $this->conn->query($q, $this->conn) or die($this->conn->error); //<--------THE ERROR IS HERE $_SESSION['userfirstname'] = $result; $this->conn->close(); } also why are you making a class to handle your database queries but then closing the connection after the first one Scott.
  19. replace the code you posted with the code i posted you may need to remove the opening <?php tag Scott.
  20. you need to include the html in your while loop like <?php $query2 = mysql_query("SELECT * from users where username = '$username' order by firstname"); while ($row = mysql_fetch_assoc($query2)) { $firstname = $row['firstname']; $lastname = $row['lastname']; //} ?> <P ALIGN=CENTER><h3>Friend Requests:</h3></P> <center> <table border="1" width="400" cellpadding="5" bgcolor="#ffffff" bordercolor="#808080" style="border-collapse: collapse;" id=""> <tr> <td align="center" width="" bgcolor="#c0c0c0"><?php print $firstname ?> <?php print $lastname ?></td> <td align="center" width="" bgcolor="#c0c0c0"><a href='../friends/Accept.php?username=<?php print $username ?>'>Accept</a> | <a href='../friends/Decline.php?username=<?php print $username ?>'>Decline</a></td> </tr> <?php } ?> Scott.
  21. you cant add the javascript code onto that but if you sent your user to one page with that on it then javascript redirected them to the download page (basically what most download sites do). that way you can display a page with your adds and a download/save window. also for the file size check out the comments on the php manual header Scott.
  22. just noticed http://nz.php.net/mysqli_query => mysqli::query() / mysqli_query() but http://nz2.php.net/mysqli_query => mysql_query() thought they would keep them more up to date then that.. Scott.
  23. your going to need PHP/Mysql. you need a mysql database to store all the information about the dogs then a php form to search the database and print out the results. you will also need some kind of admin area for the staff to add dogs and take dogs off the find a home. i recommend going through the php/Mysql tutorials here http://tizag.com/ Scott.
  24. i get redirected to http://nz.php.net/mysqli_query and it works fine? could be a mirror problem Scott.
  25. cool thanks will be using it more often Scott.
×
×
  • 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.