Jump to content

bluefrog

Members
  • Posts

    36
  • Joined

  • Last visited

Everything posted by bluefrog

  1. Was just wondering actually, would it be easier to replace the draw number? The code above will place draw number 1 for example, but all the code really does is output 1 or 2, is it possible to replace the number 1 or 2 with a string?
  2. Thank you for the reply Each ball is stored individually, I'm not really sure past that, I don;t work with databases at all normally. Here is the entire code: $select = mysqli_query($connection, "SELECT * FROM lotto where date = (select max(date) from lotto) ORDER BY draw_nr"); $rows = array(); while($row = $select->fetch_array()) $rows[] = $row; ?> <style> table { border-collapse: collapse; text-align: center; } </style> <h1><center>Results for <?php echo isset($rows[0]) ? date('l jS F', strtotime($rows[0]['date'])) : ""; ?> 49s Lotto</center></h1> <p>Draws are updated around 1pm and 6pm GMT. As requested by so many of you, the draw will now be shown in the order the balls were drawn. If you want the balls in numerical order, look to the right, or if using a mobile device, scroll right to the bottom.</p> <p> </p> <div class="draw-container"> <div> <div class="balls-heading"> <strong>Results</strong> </div> <div class="booster-heading"> <strong>Booster</strong> </div> </div> <div class="clr"></div> <div> <?php $color_mapping=array('0'=>'BLUE','1'=>'GREEN','2'=>'RED','3'=>'ORANGE','4'=>'YELLOW','5'=>'BROWN','6'=>'VIOLET', '7'=>'BLUE'); for($i = 0; $i < count($rows); $i++) { $res = explode(",", $rows[$i]['result']); $rRows = array(); echo "<p style='float:left;' class='drawnumber'>(Draw number ".$rows[$i]["draw_nr"].")</p><p> </p>"; for($j = 0; $j < count($res); $j++) echo "<img class='ball' src='http://www.mysite.co.uk/images/fortyninesballs/".$res[$j].".gif'>"; echo "<td><img class='ball booster img-responsive' src='http://www.mysite.co.uk/images/fortyninesballs/".$rows[$i]["booster_ball"].".gif'></td><p style='clear:both;'></p>"; } ?> </div> </div>
  3. Hi all, thank you for taking time to browse my thread. I have had some code written for me a while back which fetches either 1 or 2 rows from a database depending on if there are one or two rows based on the date. What it does is simply keep track of lotto results for each of the 2 daily draws along with the booster ball. Now, here's what I'm trying to do. Each row should really have it's own header such as Lunchtime or Teatime based on the draw number fetched from the database. I'm struggling a little. I understand how the code works and that I should have some kind of if/else (I think) in there, but I can't understand where or how to place it. Here is the current code <?php $color_mapping=array('0'=>'BLUE','1'=>'GREEN','2'=>'RED','3'=>'ORANGE','4'=>'YELLOW','5'=>'BROWN','6'=>'VIOLET', '7'=>'BLUE'); for($i = 0; $i < count($rows); $i++) { $res = explode(",", $rows[$i]['result']); $rRows = array(); //echo "<tr><td><p style='float:left;'>".$rows[$i]["draw_nr"].".</p></td>"; for($j = 0; $j < count($res); $j++) echo "<img class='ball' src='http://www.number49s.co.uk/images/fortyninesballs/".$res[$j].".gif'>"; echo "<td><img class='ball booster img-responsive' src='http://www.number49s.co.uk/images/fortyninesballs/".$rows[$i]["booster_ball"].".gif'></td><p style='clear:both;'></p>"; } From what I understand it fetches the results, turns them into an array and pulls each ball separately, from the rows and then appends the booster ball result for the current row. I'm thinking that it should have an if statement around $rRows array which reads if there is only a single row (based on draw number and date) and if it is outputs the code for the single row, then the else statement outputs the code for both. With a different header for each row I know I look like an idiot to you guys (and gals) who know this stuff inside out, but I am trying to learn although sadly this is WAY out of my ability at the moment. Any help as to where to place the if statement and how to get the results based on row number would be very gratefully accepted, but please don't be rude, I know I'm asking a lot, and I also know I know very little compared to the rest of you, but it doesn't give you warrant to be nasty. Thank you in advance to anybody who may be able to help me get this working, it's been driving me nuts for over 3 hours now
  4. That is what I'm trying to achieve, generate a number based on three others. Or do you mean the 'purpose' of the code. Oh you've edited your post to a "." Guess this makes no sense to people reading it now lol
  5. The array is 6 numbers, I want to take the highest three numbers and generate a fourth number based on the highest number (one less). However if the highest number is 48 and the next highest is 47, then the generated number should be 49, but no higher. If the two numbers were 48 and 49 then the number should be lower, so in this case 47 (one less than the next lowest. Works on numbers 1-49. This is for a lottery website I am setting up (hopefully). Does that make sense? It does in my head lol
  6. I am trying to write what should be a short piece of code to generate a 4th number based on three. There is an array with 6 numbers in it, the code needs to take the last three (numerical order) and generate a fourth based on some rules: if last number (array [5]) = the same as array[4] and array[5] is less than 49 then array[5] = array[5] +1 if last number (array [5]) = the same as array[4] and array[5] is equal to 49 then array[5] = array[4] -1 IF array[3] is more than 2 less than array[4] eg: Number 1,2,44,45,47,48 By these rules the new number can be 49, as although number number 5[4] would be the same as the generated number ([5]-1) it is less than 49 so can be number 6[5] +1 instead. Number 1,2,44,45,46,48 By these rules the generated number can be 47, as number 5[4] is more than two away from the last number [5] Number 1,2,44,45,48,49 By these rules the generated number would be 47, as the last number [5] is 49 and the second last [4] is the next number in reverse sequence, so cannot go higher than 49 and can't use the next number down, so uses the next number [4] -1 Here is what I've cobbled together - no laughing please I'm new: <?php //$lunch = explode(",",$lt_results); $lunch = array("1","1","1","44","47","48"); sort($lunch); echo '<br>'; echo $lunch[3]; echo ' - '.$lunch[4]; echo ' - '.$lunch[5]; $last = --$lunch[5]; echo '<br>Last = '.$last; if ($last == $lunch[4]){ echo "<br>Ball 5 & pick are the same"; if ($lunch[5]<"49"){ $last = $lunch[5]; echo $last; } } else { echo "a is smaller than b"; } ?>
  7. @ginerjim lol, I intend to, I find php a most versatile language, however I guess by the time I've learned it something will have replaced it lol. I was really looking to see if I had selected the correct function (?). @psycho thanks. Because I'm still wet behind the ears so to speak, I was having trouble deciding between the two, they both seemed to do the same job which is why I posted, a clarification really. But sound advice, thanks
  8. Thank you Barand, exactly the info I was looking for. @jinerjm, yes I have but was more than a little confused by some of the examples - remember I don't code php, I am very very new.
  9. Hi, I have a group of numbers like this: 1 - 2 - 3 - 4 I want to break that single variable apart and enter the number only into an array, then print out each number as needed (as entered into the array). Trouble is I have literally no idea where to even begin, and little knowledge of php, probably less than basic. I am assuming I will need something like preg or explode? Any brief examples would be very much appreciated, also, if I wanted to list these from lowest to highest is that much or a task? Many thanks in advance
  10. Ah I got it. Is there a shorter version than this: function ball_callback($atts,$content,$tag){ //collect values, combining passed in values and defaults $values = shortcode_atts(array( 'num' => 'other' ),$atts); //based on input determine what to return $output = ''; if($values['num'] == '1'){ $output = 'output for 1'; } else if($values['num'] == '2'){ $output = 'output for 2'; } else if($values['num'] == '3'){ $output = 'output for 3'; } else{ $output = ' '; } return $output; } add_shortcode('ball','ball_callback');
  11. Actually that only returns the 'else' statement ;/
  12. No I understand how to create and use a shortcode, I've done a few, I'm struggling with the function element. Barand suggests a good solution, however I'm a little confused as to how to correctly write the number from the shortcode to the function. Would something like this work: function ball_number($atts,$content,$tag){ $values = shortcode_atts(array( 'ball' => ' ' ),$atts); $output = ''; if($values['ball'] == '1'){ $output = 'image code for ball number 1'; } else if($values['ball'] == '2'){ $output = 'image code for ball number 2'; } else if($values['ball'] == '3'){ $output = 'image code for ball number 3'; } else{ $output = ' '; } return $output; } add_shortcode('ball','ball_number'); Thanks for all of your input so far, it's appreciated
  13. Sorry you'll have to bare with me, I'm not great with php as I said. How do I get the number into a variable? The number will literally just be written into a shortcode (which will be the same for each number) with the only difference being the number in the shortcode: [myshortcode num=40] [myshortcode num=13] [myshortcode num=6] for example. Thanks in advance
  14. I have no idea how to properly describe this topic as I'm fairly new to php, but here is a description of what I am trying to do: This is firstly for a wordpress functions file Ok what I am trying to achieve is have a small piece of code (in this case a wordpress shortcode) read a number in plain text: e.g. [myshortcode num=43] And replace the shortcode input (43) with an image named the same (43.jpg (http://www.mysite/path/43.jpg")) This is for a lottery style site where I want to put my picks for the day so I have 49 numbers in total. And each number is currently a full line of html code - I really need to make input faster lol. I have tried 'if and' I have tried 'if or' but I'm struggling. Anybody know how to take that and turn into a function? I know how to get it into wordpress and make it a shortcode, I just need help with the actual function side of things, my code was incredibly long and didnt work lol Thank you all in advance
  15. Solved this myself like this: $mail->AddAddress($_POST['email'],"Subject Of The Email"); Thanks for all your help though
  16. Marking this as solved because I added a small piece of javascript to handle it which works. Here's the code for anybody trying the same thing: <form name="form" method="post" action="contact.php"> <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="compare"> <tbody> <tr> <td class="col1"><label for="to_email">Email</label></td> <td class="col2"><input type="text" name="email" id="email" value="<?php echo $contact_email ;?>"/></td> <td class="note"><?php if (isset($form_incomplete)) { echo '<span class="red">Required.</span>'; } else { echo 'Required.';} ?> Pre-filled from Data, replace if required.</td> </tr> <tr> <td><label for="fullname">Name</label></td> <td><input type="text" name="fullname" id="fullname" value="<?php echo $contact_first.' '.$contact_last; ?>" /></td> <td class="note"><?php if (isset($form_incomplete)) { echo '<span class="red">Required.</span>'; } else { echo 'Required.';} ?> Pre-filled from Data, replace if required.</td> </tr> <tr> <td colspan="3"> <center> <select name="menu"> <option value="#">Select subject...</option> <option value="This is for value no.2">Appointment</option> <option value="This is for value no.2">Value No. 2</option> <option value="This is for value no.3">Value No. 3</option> <option value="This is for value no.4">Value No. 4</option> <option value="This is for value no.5">Value No. 5</option> <option value="This is for value no.6">Value No. 6</option> </select> <input value="Populate" type="button" onclick="document.form.accept.value=document.form.menu.options[document.form.menu.selectedIndex].value;document.form.textareaaccept.value=document.form.menu.options[document.form.menu.selectedIndex].value;"> <select name="menu2"> <option value="#">Select message...</option> <option value="This is for value no.1">Value no.1</option> <option value="This is for value no.2">Value No. 2</option> <option value="This is for value no.3">Value No. 3</option> <option value="This is for value no.4">Value No. 4</option> <option value="This is for value no.5">Value No. 5</option> <option value="This is for value no.6">Value No. 6</option> </select> <input value="Populate" type="button" onclick="document.form.message.value=document.form.menu2.options[document.form.menu2.selectedIndex].value;document.form.textareamessage.value=document.form.menu2.options[document.form.menu2.selectedIndex].value;"> </center> </td> </tr> <tr> <td><label for="subject">Subject</label></td> <td><input type="text" id="accept" name="subject"/></td> <td class="note"><?php if (isset($form_incomplete)) { echo '<span class="red">Required.</span>'; } else { echo 'Required.';} ?> Change as you wish.</td> </tr> <tr> <td class="indent"><label for="query">› Default Message</label></td> <td><textarea name="query" id="message" rows="5" cols="30"><a href="">test</a></textarea></td> <td class="note">Change as you wish.</td> </tr> </tbody> </table> <input name="btnSubmit" type="submit" onclick="javascript: return validate();" value="Send Email" /> </form>
  17. Just basic at the moment as I have no idea where to begin if I'm honest. I'm using the standard phpmailr & smtp classes along with the form parser here: <? ob_start(); if(isset($_POST['btnSubmit'])) { require("class.phpmailer.php"); $mail = new PHPMailer(); //Your SMTP servers details $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "yourmailserver.com or localhost; // specify main and backup server or localhost $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "[email protected]"; // SMTP username $mail->Password = "password"; // SMTP password //It should be same as that of the SMTP user $redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form $mail->From = $mail->Username; //Default From email same as smtp user $mail->FromName = "Display Name"; $mail->AddAddress("[email protected]", "your name"); //Email address where you wish to receive/collect those emails. $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = $_POST['subject']; $message = "Name of the requestor :".$_POST['fullname']." \r\n <br>Email Adrress :".$_POST['email']." \r\n <br> Query :<a href="http://www.google.com">GOOGLE!</a>".$_POST['query']; $mail->Body = $message; if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; header("Location: $redirect_url"); } ?> And the HTML elements here: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Contact Us</title> <script language="javascript"> function validate() { if(document.getElementById("fullname").value=='') { alert("Please provide your full name"); document.getElementById("fullname").focus(); return false; } if(document.getElementById("email").value=='') { alert("Please provide email address"); document.getElementById("email").focus(); return false; } if(document.getElementById("subject").value=='') { alert("Please provide subject line"); document.getElementById("subject").focus(); return false; } if(document.getElementById("query").value=='') { alert("Please enter your query"); document.getElementById("query").focus(); return false; } } </script> </head> <body> <form name="form" method="post" action="contact.php"> <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1"> <tbody> <tr><td colspan="3" align="center"><h2>Contact Us</h2></td></tr> <tr> <td width="39%" align="right" ><strong>Full Name<font color="#ff0000"> *</font></strong></td> <td width="1%" ><div align="center">:</div></td> <td width="60%" height="25"><input type="text" name="fullname" id="fullname" /></td> </tr> <tr> <td width="39%" align="right" ><strong>Email<font color="#ff0000"> *</font></strong></td> <td width="1%" ><div align="center">:</div></td> <td width="60%" height="25"><input type="text" name="email" id="email" /></td> </tr> <tr> <td align="right"><strong>Subject<font color="#ff0000"> *</font></strong></td> <td ><div align="center">:</div></td> <td height="25"><input type="text" name="subject" id="subject" /></td> </tr> <tr> <td align="right" valign="top"><strong>Please Type Your Query If Any<font color="#ff0000"> *</font> </strong></td> <td ><div align="center">:</div></td> <td height="25"><textarea name="query" id="query" rows="5" cols="30"></textarea></td> </tr> <tr> <td colspan="2" align="right"></td><td><input name="btnSubmit" type="submit" onclick="javascript: return validate();" value="Submit" /></td> </tr> </tbody> </table> </form> </body> </html> These are the basics which I have changed to work, then used variables to pre-fill some fields such as name and email.
  18. Hmmm, no takers so far - is this even possible? I think the subjects could be pre-filled in the script and selectable via radio boxes, would that be correct?
  19. @Kingy, yeah I did think of that but it kept giving the error of string failed, please supply email address. I echoe'd the string being passed and it was correct. @BigGrecian, so if I replace the "$mail->AddAddress("email address to send to", "Name");" to "$to = '[email protected]';" is there anything on the form or elsewhere on this form I will need to change? I'm using the standard smtp classes. Oh and thank you very much both, I'm new to php and it's driving me nuts lol
  20. Hi I'm new here and a very novice php coder, so please forgive me if this is a stupid question. I am trying to code a form which has the following characteristics; Pre filled email (to) Pre filled subject (selection) Pre filled message (selection) with links (html) I can code the form itself, html is easy-ish, what I'm having trouble with is populating the subject and message fields. I know how to include an external file with variables in, but I have no idea how to make them into a selectable form, also I have found that the <textarea> tag strips html so live links cannot be included - which I need. I am not using a database except if you consider a flat-file a DB, settings are stored in a php document. Any and all help welcomed Thanks
  21. Hi I have a script (below) which is for a standard email form. However, I would like to be able to use it to email people instead, I know it's just a case of setting the $mail->AddAddress to the details of the user I'm mailing (set in a variable of $contact_email) but I can't seem to get it right. I've tried the following: $mail->AddAddress($contact_email); $mail->AddAddress = $contact_email; $mail->AddAddress $_POST['email']; (taken from the html form) Any idea's? <? ob_start(); if(isset($_POST['btnSubmit'])) { require("class.phpmailer.php"); $mail = new PHPMailer(); //Your SMTP servers details $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "mydetails"; // specify main and backup server or localhost $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "mydetails"; // SMTP username $mail->Password = "mydetails"; // SMTP password //It should be same as that of the SMTP user $redirect_url = "redirectdetails" ; //.$_SERVER['SERVER_NAME']; //Redirect URL after submit the form $mail->From = $mail->Username; //Default From email same as smtp user $mail->FromName = "test User"; $mail->AddAddress("email address to send to", "Name"); //Email address where you wish to receive/collect those emails. $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = $_POST['subject']; $message = "Hi[name]".$_POST['fullname']." \r\n <br>Email Adrress :".$_POST['email']." \r\n <br> \r \n".$_POST['query']; $mail->Body = $message; if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; header("Location: $redirect_url"); } ?> Thanks in advance
  22. Well to get the primary values I used this (after connecting etc...) $query = "SELECT day, month, year, event, type FROM event"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $day = $row[0]; $month = $row[1]; $year = $row[2]; $event = $row[3]; $type = $row[4]; echo "Day :$day <br>" . "Month : $month <br>" . "Year : $year <br><br>"; "Event : $event <br><br>"; "type : $type <br><br>"; } Effectively to read the data, assign the variable and then print to screen to show the output. I have tried then using a basic html form with the variable names inserted (in php tags) to write the data into the fields. All this worked ok but the trouble I am having is re-writing the new data to the database. The form has to somehow write back to the db, but only on the chosen row (in this case not by ID but rather type) all of the values input by the user such as year, from say 2010 to 2011 as the new value. The examples I have seen post to an external php file, but don;t give any information on the contents of the php file lol, since I am VERY new to php and mysql, I'm fairly stuck at this point. I understand how to write back to the table by means of hardcoded information, what I'm stuck with is converting the new data into a variable (or similar) and writing the variable to the sql string for writing back. Thanks
  23. Your first problem is using word, try using notepad instead. Secondly, when you are saving the file, the 3 character extension (ie. .txt .doc .jpg etc) is being overwritten as a text file (.txt) If you have extensions visable, just right click and rename the file back to .php If you dont have extensions visable you will need to make them visable, depending on your version of windows this is different however a quick google search for show extension windows XX (where XX is your version such as XP vista 7 etc...) will give you as much information as you need.
  24. MOD: Thanks for moving to the correct forum - much appreciated! OK, I've taken a look around and cannot find a complete tutorial on how to do this. I have created a database with a table and the following fields; id, day, month, year, event, type What I am trying to do is read the data held in the table by referencing the type field (unique data), have it populate data firleds which are user editable and then once all changes are made have it update into the table. I can't imagine that this is that hard at all, but I cannot for the life of me figure it out! Anybody got a tutorial or some code which will do this?
  25. Thank you so much for the information - it's all valuable when you're learning!! I found out why the default wasn't working - wrong image name lol, all working now. Thank again.
×
×
  • 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.