Jump to content

ameyemad

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Everything posted by ameyemad

  1. Fantastic, thank you so much!
  2. No it's not there. We need to see where to data is actually being inserted into the database, so there should be a code similar to @mysql_query("INSERT INTO table SET ......");
  3. The USERNAME can be letters, numbers or underscore only. So some examples: boy_man123 fooBarX 6_foo So let's say the string is: $str = "Hello @6_foo, how are you? To convert to: Hello @<a href="message.php?member=6_foo">6_foo</a>, how are you?
  4. Can you post the source script for function "AddRecipe"?
  5. Hi I'm trying to match @USERNAME in a string and replace it with @<a href="message.php?member=USERNAME">USERNAME</a> I've tried a few different methods: preg_replace ('/@(.*?)/', '<a href="message.php?member=$1">$1</a>', $str) and also * and \@ but i just can't seem to get it to work. any help would be appreciated!
  6. I usally use the strtotime function.. http://php.net/manual/en/function.strtotime.php Some handy examples there too.
  7. After hours and hours spent on this I have a solution.
  8. Hello guys. I'm pulling my hair out over this one, and some help will def be appreciated. Here are the 2 tables: table 1: prizes idprize_namemax_winnerswin_type 1$15daily 2$22daily 3$51weekly table 2: logs idprize_idwin_time 111280494274 211280494300 331280493899 How can I make it so that I can join the 2 tables, using prize.id=log.prizeid, then choose a prize that has not reached maximum winners for the period (win_type). Query which I have been working on which isn't working properly: select prize.id,prize.prize_name,ifnull(county,0),tp.prize_id,prize.max_winners,tp.win_time,prize.win_type from prizes prize left join ( select prize_id,win_time,count(*) as county from logs ) tp on prize.id=tp.prize_id where prize.max_winners>'0' and ((prize.win_type='once' and prize.max_winners>county) or (prize.win_type='hourly' and tp.win_time>'$_last_hr')) order by rand() limit 1 There is a few different "win_types"... -once (which only gets awarded once) -hourly -daily -weekly I can get it to select a prize, but as soon as I add the "county" it stops working. I've tried so many methods to get this work but now it's time to throw in the towel and get some help please. Thanks in advance. If you require more info please let me know.
  9. See bold text please. I want to get the closest to grouping amount possible to the amount 120.
  10. Okay sure. So the 2 tables... TABLE 1 - users -------------------- username TABLE 2 - accounting -------------------- amount username Some data in table 1: bob jill mary hank steven Some data in table 2: bob 55 jill 76 mary 11 bob 8 hank 12 hank 9 steven 77 jill 74 Ok, so let's say I want to find users from table 2 that have an amount totalling 120. So the output would be: steven 77 hank 21 mary 11 And that's all that's displayed as that all that equals 120 or under. This can be randomized though as there is other combinations in the table which could equal 120 or under, but you should be able to understand what I'm after.
  11. Do you require more information? This has really got me stumped, and there might not be a way of doing it as I've tried searching all over. Thanks
  12. Any help would be greatly appreciated :-)
  13. I'm trying to randomly select records using sum, but to a maximum total only. How would this be done? TABLE 1 - users -------------------- username TABLE 2 - accounting -------------------- amount username I want to randomly select as many records in table 1 so that ALL sum(amount) total UNDER a specific amount. so basically i need to add up each sum(amount) or something, but I have no idea how to do this. I know that selecting sum(amount) gives me the total for each username, but I want a list so the total of all sum(amounts) is less than a number I specify. Any help would be great! Thank you in advance.
  14. thanks for the help, i worked out the problem i was having. thanks again!
  15. any help please?
  16. I think that's really close, but I get this error: Unknown column 't2.tid' in 'on clause' any ideas?
  17. sorry but t2.tid doesn't work as i stated in first post
  18. Any help please?
  19. I've been having some problems with left join and grouping, the results are just not working properly. For example... lets say I have 2 tables... table1 ---------- id message table2 ---------- id tid message time Query... $query="Select t1.id,t1.message,t2.id,t2.message from table1 t1 left join table2 t2 on t1.id=t2.tid order by time desc"; Now, if t2.tid can have multiple entries the same, how do you group them properly so that the entry that has the highest t2.time is chosen and nothing else? I've tried group by t2.tid but it doesn't work. Thank you.
  20. try this alternate code $db = mysql_connect("localhost"); mysql_select_db("videoshop", $db); $score = 0; foreach ($_POST['question'] as $key => $value){ $query = "SELECT correct FROM quiz WHERE id = '".$key."' and correct = '".$value."'"; echo "<BR>"; echo $query; $result = mysql_query($query); if($result[correct]){ $score++; } } echo "<br>"; echo "your score is ".$score."/5"; have you got this page up somewhere for viewing?
  21. you should save "correct" in this table as either 1,2,3 or 4 and not the actual answer.
  22. for ($i=0;$i<10;$i++){ $candidate=1; $c1=1; $canamts = 6; echo"<label><input type='checkbox' name='$c1' onClick='return KeepCount()' value='1' id='votes_0' />$candidate</label><br>"; $c1++; $candidate++; } you can change 10 to anything you like. is that what you want?
  23. i also noticed you have... $nameField = $_POST['name']; $emailField = $_POST['email']; $phoneField = $_POST['phone']; $messageField = $_POST['message']; $mailinglistField = $_POST['mailinglist']; and then you have... Name: $name <br> Email Address: $email <br> phone: $phone <br> Message: $message <br> Mailing List: $mailinglist
  24. ok, full script: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body> <p> <form name="form1" method="post" action="quiz2action.php"> <?php $db = mysql_connect("localhost"); mysql_select_db("videoshop", $db); $queryquestions = "SELECT * FROM quiz" or die(); $resultquestions = mysql_query($queryquestions) or die(); while($rowquestions = mysql_fetch_array($resultquestions)) { $questionid = $rowquestions['id']; $question = $rowquestions['question']; $answerone = $rowquestions['option1']; $answertwo = $rowquestions['option2']; $answerthree = $rowquestions['option3']; $answerfour = $rowquestions['option4']; echo " <form action=\"quizaction.php\" method=\"post\"> <b>Question $questionid: $question</b><br> <input type=\"radio\" name=\"question[$questionid]\" value=\"1\"> $answerone <br> <input type=\"radio\" name=\"question[$questionid]\" value=\"2\"> $answertwo <br> <input type=\"radio\" name=\"question[$questionid]\" value=\"3\"> $answerthree <br> <input type=\"radio\" name=\"question[$questionid]\" value=\"4\"> $answerfour <br>"; echo "<br><br>"; } ?> </p> <label> <input type="submit" name="button" id="button" value="Submit"> </label> </form> <p> </p> </body> </html> then in quiz2action.php <?php $db = mysql_connect("localhost"); mysql_select_db("videoshop", $db); $score = 0; foreach ($_POST['question'] as $key => $value){ $query = "SELECT * FROM table WHERE id = '".$key."' and correct = '".$value."'"; $result = mysql_query($query); if($result){ $score++; } }
  25. or php version header('Refresh: 3; url=http://www.example.org/');
×
×
  • 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.