Jump to content

forumnz

Members
  • Posts

    735
  • Joined

  • Last visited

Everything posted by forumnz

  1. Thanks but what is the function? I want to look it up on php.net. Thanks, Sam.
  2. What should I look up on php.net regarding swapping bg colors in multiple row displays. It has a % in it i think. I want row 1 to have bg color $a and row 2 to have $b, 3 to have $a, 4 to have $b etc. Thanks.
  3. Awesome... looking better. Problem: Instead of getting: Far North Kaipara Whangarei I get: Kaipara Whangarei Whangarei (so Whangarei is repeating and Far North is not displaying) We must be close now?
  4. Nice try... still doesn't work though. Now, I get: K W Instead of: Far North Kaipara Whangarei (so the first one is missing and they aren't going in columns. Should be: 1 6 2 7 3 etc 4 5 not: 1 2 3 4 5 6 etc Any ideas? Thanks heaps! Big help!
  5. Ok, Database db1 Table structure for table ffcats Field Type Null Default id int(4) Yes NULL pid int(4) Yes name varchar(25) Yes Dumping data for table ffcats 92 69 Papakura District 91 69 North Shore City 90 69 Manukau City 89 69 Franklin 88 69 Auckland City 213 83 Pakaraka 212 83 Paihia 85 68 Whangarei 84 68 Kaipara 83 68 Far North 82 0 Southland
  6. <?php $cat = $_GET['cat']; include('../connectdb.php'); $sql = mysql_query("SELECT * FROM ffcats WHERE pid='$cat' ORDER BY id ASC"); if ($cat == "") { include('nonechosen.php'); } else { echo "<table><tr><td>"; while($row = mysql_fetch_array($sql)) { $no = $name = $row['name']; $a = $row['id']; echo "<a href=?cat=" . $a . ">" . $name . "</a><br>"; } echo "</td></tr></table><br />"; } ?> At the moment I get: 1 2 3 4 5 6 7 8 etc. How can I get what I previously stated? Thanks heaps!
  7. I'm testing something and using the code provided by cooldude832 (modified), but I just can't make it work for me. Basically what I'm trying to do is pull rows from a db (sorted), and place them in columns like: 1 6 11 2 7 12 3 8 13 4 9 14 5 10 15 How do I do that? Please help this is important (and frustrating ) Thanks, Sam.
  8. Can someone please show me a simple way of adding 1, each time a while loop is performed? Thanks, Sam.
  9. How do I add num_rows into this so that I can count the results? Code snippet: <?php $sql = "SELECT * FROM fflists WHERE $op='$trim' AND (keywords LIKE '%$key%' OR business_name LIKE '%$key%') AND (c1 LIKE '%$cuis%' OR c2 LIKE '%$cuis%' OR c3 LIKE '%$cuis%' OR c4 LIKE '%$cuis%' OR c5 LIKE '%$cuis%') ORDER BY keywords ASC"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $name = $row['business_name']; $a = $row['id']; echo "<a class=two href=http://www.foodfinder.co.nz/Browse/Listing/?id=" . $a . ">" . $name . "</a><br>"; } } ?> Thanks, Sam.
  10. Here is the error: FUNCTION foodfinder.RAND does not exist What does it mean? Sam.
  11. Heres my code which is supposed to select a random row from a db. <?php include('connectdb.php'); $result = mysql_query("SELECT * FROM fflists ORDER BY RAND () LIMIT 1"); while($row = mysql_fetch_array($result)) { $business_name = $row['business_name']; echo $business_name; } ?> And the error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/www/vhosts/foodfinder.co.nz/httpdocs/rowtest.php on line 5 Thanks, Sam.
  12. Heres my code followed by the error. Any idea? Thanks, Sam. <?php include('connectdb.php'); $id = "100000"; $result = mysql_query("SELECT * FROM fflists WHERE id=`$id` AND active="1" LIMIT 1"); while($row = mysql_fetch_array($result)) { $business_name = $row['business_name']; } mysql_close($con); ?> Error: Parse error: syntax error, unexpected T_LNUMBER in /usr/local/www/vhosts/foodfinder.co.nz/httpdocs/Browse/Listing/listinginfo.php on line 6
  13. Can I use that in a script or do I have to edit php.ini? Thanks.
  14. Hey, I am using the mail function to send an email from my site. If I have the email address in the From: part, then it says in the email that it's from "no-reply@domain.com". However I want it to say that the message is from "John Doe [no-reply@domain.com]" (as displayed in Outlook). How do I achieve that? At the moment I have: $headers = "From: John Doe [no-reply@domain.com]\r\n"; Which returns: User Joen Doe [johndoe@plesk-bsd.hosting.isx.net.nz] Please help, Thanks, Sam.
  15. Thanks! Any more critique is appreciated! Sam.
  16. My form correctly submits the right fields to the register-process.php for validation and to insert into db. Problem is, the username, fname and lname are coming up blank. It worked once (and inserted a blank username, fname and lname into the db, but now won't because it's still inserting blank fields which already exist). Please help, Sam. Code: <?php //Start session session_start(); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; include('connectdb.php'); //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { if(!get_magic_quotes_gpc()) { $str = @trim(mysql_real_escape_string($str)); } else { return @trim($str); } } //Sanitize the POST values $fname = clean($_POST['fname']); $lname = clean($_POST['lname']); $login = clean($_POST['login']); $password = clean($_POST['password']); $cpassword = clean($_POST['cpassword']); //Input Validations //Check for duplicate login ID $qry = "SELECT count(*) AS c FROM ffusers WHERE login='$login'"; $result = mysql_query($qry); if($result) { $result_array = mysql_fetch_assoc($result); if($result_array['c'] > 0) { $errmsg_arr[] = 'Login ID already in use'; $errflag = true; } @mysql_free_result($result); } else { die("Query failed"); } //If there are input validations, redirect back to the registration form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: register-form.php"); exit(); } //Create INSERT query $qry = "INSERT INTO ffusers(firstname, lastname, login, passwd) VALUES('$fname','$lname','$login','".md5($_POST['password'])."')"; $result = mysql_query($qry); //Check whether the query was successful or not if($result) { header("location: register-success.php"); exit(); }else { die("Query failed"); } ?>
  17. Thanks! I have got it working. One more problem - i have 2 rows in my db (one with aid=138 and the other aid=139). They both have keywords and names with the letter a, and when I search with keywords 'a' and aid=139, both come up, when only one should come up. I hope that makes sense? Any idea why it does that? Thanks heaps! Sam.
  18. My code is as follows and produces the error. I really don't know what to do? Thanks, Sam. <?php $dest = &$_GET['dest']; $subs = &$_GET['subs']; $origin = &$_GET['origin']; $keywords = &$_GET['keyword']; if($origin != "") { $cat = $origin; } elseif($subs != "") { $cat = $subs; } elseif($dest != "") { $cat = $dest; } $trim = trim($cat); $key = trim($keywords); include('connectdb.php'); $sql = mysql_query("SELECT * FROM fflists WHERE aid='$trim'"); /* AND keywords LIKE '%$key%' OR business_name LIKE '%$key%' ORDER BY keywords ASC"); */ $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $name = $row['name']; $a = $row['id']; echo "<a href=index.php?cat=" . $a . ">" . $name . "</a><br>"; } ?> Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #3' at line 1
  19. www.netport.co.nz/foodfinder Thanks!
  20. http://netport.co.nz/foodfinder/ You will see (using IE) my site does not diaplay the background color correctly. I have set the menu and main content to have the same bg color, but it doesn't look right. Also, how do I make the bg color go as far down as both the floating divs? Thanks heaps! Sam.
  21. Hi, Nice try but it doesn't work. I really need help with this - so frustrating. I don't want the code, I just want assistance (I would rather learn it as well). Thanks! Sam.
  22. echo "<table><tr><td>"; while($row = mysql_fetch_array($sql)) { $name = $row['name']; $a = $row['id']; echo "<a href=browse.php?cat=" . $a . ">" . $name . "</a><br>"; } echo "</td></tr></table>"; }
×
×
  • 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.