Jump to content

AyKay47

Members
  • Posts

    3,281
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by AyKay47

  1. target='_blank'?
  2. this should be done in the query itself for optimization, you should either use my suggestion or format the date correctly like PFM suggested.
  3. There are two ways to grab values from multiple tables; a subquery or a join. Can you post the final solution query please.
  4. http://dev.mysql.com/doc/refman/5.0/en/join.html
  5. Again, the HAVING clause is used in conjunction with a group by clause, it does not replace the where clause, quite simply, the query you just wrote is wrong. I'm not here to argue, OP this is the query you should use for this, provided by Little Guy select t1.*, t2.img_thumb from table1 t1 inner join table2 t2 on (t1.user_id = t2.img_id_fk) order by rand() limit 5;
  6. This doesn't let me search for a specific word/value sure it does: $array = array('blue', 'yellow', 'red', 'blue', 'blue', blue', yellow'); $count_arr = array_count_values($array); $blue_count = $count_arr['blue']; //prints 4
  7. right, your suggestion of using an inner join instead is the correct solution.
  8. http://www.php.net/manual/en/function.array-count-values.php
  9. I would do this in the query: select day(date_field) as day, monthname(date_field) as month, year(date_field) as year from table then using php you could do something like this. $query = mysql_query("select day(date_field) as day, monthname(date_field) as month, year(date_field) as year from table"); while($row = mysql_fetch_assoc($query)) { $day = $row['day']; $month = $row['month']; $year = $row['year']; } *pseudo code*
  10. <a href="delete.php?username=<?php echo $username; ?>">Delete User</a> Delete.php: <?php mysql_connect ("localhost","root","") or die("Cannot connect to Database"); mysql_select_db ("test"); $username = $_GET['username']; $username = mysql_real_escape_string($username); mysql_query ("DELETE FROM members WHERE username='$username'") or die ("Error- user has not been deleted"); echo "User has been deleted"; //header("Location: personaldetails.php"); ?>
  11. I forgot the order by rand(), the having clause is used in conjunction with the group by clause, you can use IS NULL and IS NOT NULL in the where clause.
  12. Is $username defined elsewhere? the query syntax is fine, my guess is that $username is not defined. what is the error? Also, it's mysql_error(), not mysql_error
  13. if (isset($_POST['Submit'])) { $username=mysql_real_escape_string(trim($_POST['username'])); //this needs to match the nameattr of the input field $sql = "select * from memberdetails WHERE username='$username'"; $result = mysql_query ($sql); *snippet*
  14. post the entire updated code, using code or php tags
  15. you are using the same name attribute for the submit button and the text field. Change the text field name to something that makes sense, like "username"
  16. you are trying to compare a resource to an integer, the code should read: $sqlid = "select * from temp where Email='".$a[8]."'"; $idresult = mysql_query($sqlid) or die(mysql_error()); $res = mysql_fetch_assoc($idresult); if (mysql_num_rows($idresult) > 0) { $tempid = $res['ID']; die('sql id:' . $tempid . 'or' . $res['ID']. 'or ' . $sqlid ); } also, don't use die()'s to display messages, they are very user unfriendly.
  17. select t1.user_email, t2.img_thumb from table_1 as t1 left join table_2 as t2 on t1.user_id = t2.img_id_fk where t2.img_thumb is not null Typically you want to name fields so they make sense with what they hold and with relationships, a user id is not an image id..
  18. Typically you'll return false on the submit button click and call .submit() on the form element in your function. Really can't help any further given a picture and a form..
  19. Oh, right, how are these values initially being inserted?
  20. It completely breaks the encapsulation of a function etc by introducing variables from the global scope.. Wordpress is poorly coded..
  21. check marked as null? I'm trying to wrap my head around the logic here, but I haven't been given enough information, so it's hard to tell.
  22. I would simply set the arg $value to null as default: setlevel($world,$coords,$var,$value = null) Then, if $b == 0, do not pass a value for that arg: if($b == 0) setlevel($p,$co,"board"); which will keep $value as NULL in your function. Depending on your logic for this, the best option would be to change the mysql field definition to default NULL, changing the value when yes is selected.
  23. we can't help you with this without seeing all of the relevant code.
  24. I would use an input array for this, set the input name to an array format: <input name="quantity[]" type="text" value="" size="6" maxlength="2" /> Then iterate the field values, adding the value to the previous value each iteration: $total_quantity = 0; foreach($_POST['quantity'] as $value) { $value = intval($value); //some sanitization to make sure the value is an integer $total_quantity += $value; } This eliminates the need for a regex and multiple loops.
  25. Are you using a date/datetime field to store the date in your db 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.