Jump to content

mrdamien

Members
  • Posts

    186
  • Joined

  • Last visited

Everything posted by mrdamien

  1. $sql = "UPDATE users SET ".$_SESSION['Money']." = ".$_SESSION['Money']." - 15 AND UPDATE users SET ".$_SESSION['badge1']." = 1"; periods for string concatenation
  2. if (($_SESSION['Money'] >= 15) and ($_SESSION['badge1'] == 0)){ also, I'm pretty sure you meant to use '==' instead of '=' (You must have open/closing parentheses for if() statements)
  3. If you mean the second child, then use: <?php $x = new SimpleXmlElement($content); $children = $x->children(); $entry = $children[1]; // Child[1] is the second element. echo "<a href='$entry->link' title='$entry->title'>" . $entry->title . "</a>"; ?> If you mean the first sub-child of the first node, then use: <?php $x = new SimpleXmlElement($content); $level1 = $x->children(); $level2 = $level1->children(); $entry = $level2[0]; echo "<a href='$entry->link' title='$entry->title'>" . $entry->title . "</a>"; ?>
  4. <?php $x = new SimpleXmlElement($content); $children = $x->children(); $entry = $children[0]; // Child[0] is the first element. echo "<a href='$entry->link' title='$entry->title'>" . $entry->title . "</a>"; ?>
  5. If you can't install anything, I've used http://www.fpdf.org/ in the past, and it works well for simple PDFs.
  6. Learn to use your database: http://www.phpfreaks.com/tutorial/php-basic-database-handling http://ca.php.net/manual/en/function.mysql-query.php Learn about forms: http://www.tizag.com/phpT/forms.php http://www.w3schools.com/php/php_forms.asp Learn about sessions: http://www.phpfreaks.com/tutorial/sessions-and-cookies-adding-state-to-a-stateless-protocol http://ca.php.net/manual/en/function.session-start.php Then put them together.
  7. Generating them real-time everytime would probably strain your server anyways. Instead, set up a cron job to generate the image every X amount of minutes, and store it. Then just link to that image.
  8. Add this: style="margin-top:-3px;" to this: <input type="text" class="search_input" value="To search, type and hit enter" name="s" id="s" onfocus="if (this.value == 'To search, type and hit enter') {this.value = '';}" onblur="if (this.value == '') {this.value = 'To search, type and hit enter';}" /> <input type="text" class="search_input" value="To search, type and hit enter" name="s" id="s" onfocus="if (this.value == 'To search, type and hit enter') {this.value = '';}" onblur="if (this.value == '') {this.value = 'To search, type and hit enter';}" style="margin-top:-3px;" />
  9. Are you tracking what Message ID each message is in reply to? If not, you'll probably need something along these lines: conversation( convoID, replyTo, messageID ) When a user sends a new message, create a new row. This row should contain (a new convoID, null replyTo, and the id of the message) When a user replies to a message, use the convoID from the replying message. This way your data looks like this: (user1/2 and user3/4 are conversing) messages: 1, user1, 'yo' 2, user2,' hey' 3, user1, 'whats up?' 4, user2, 'not much' 5, user3, 'I need help' 6, user4, 'too bad' conversations: 1, null, 1 // first conversation, not a reply, message1 1, 1, 2 // first convo, replying to message1, message2 1, 2, 3 // first convo, replying to message2, message3 1, 3, 4 // first convo, replying to message3, message4 2, null, 5 // 2nd convo, not a reply, message5 2, 5, 6 // 2nd convo, replying to message5, message6 Find convoID of the message "SELECT * FROM convos WHERE replyID = $messageID" Find last convoID = "SELECT convoID FROM convos ORDER BY convoID DESC LIMIT 1" get list of messageIDs in a convo = "SELECT * FROM convos, messages INNER JOIN messages ON convos.messageid = messages.messageid WHERE convoID = $id"
  10. <?php #congress.php while($row = mysql_fetch_assoc($result)){ extract($row); echo "<tr><td valign=\"top\">"; echo "<td valign=\"top\"><div align=\"left\"><b><span class=\"style5\">$name</span></b></div>"; echo "<td valign=\"top\"><span class=\"style12\">$party</span>"; echo "<td valign=\"top\"><span class=\"style12\">$district_phone</span>"; echo "<td valign=\"top\"><span class=\"style12\">$dc_phone</span>"; if ($email == "NA"){ echo "<td valign=\"top\"><span class=\"style12\"></span>"; }else{ echo "<td valign=\"top\"><span class=\"style12\"><input type=\"checkbox\" name=\"id[$ID]\" value=\"1\" /></span>"; } echo "<td valign=\"top\"><div align=\"left\"><b><span>$email $ID</span></b></div></div></a>"; echo "</td></tr>\n"; } ?> <?php # And the sendmail.php file has been updated as follows: foreach($_POST['id'] as $id=>$one){ $query = mysql_query( sprintf( "SELECT email FROM Sheet1 WHERE ID = %d", $id ) ); $row = mysql_fetch_assoc($query); $sent = mail($row['email'], "subject", "message"); // You must update these to send a real email. (Similar to what you did in congress.php if($sent){ print "Your mail was sent successfully"; }else{ print "We encountered an error sending your mail"; } } ?> I just fixed a few things for you that should help you out.
  11. Seems fine. How is it 'hacky' ? What do you want it to look like ?
  12. ... <tr><td id="box"><input type="checkbox" name="activities" value="1" /></td><td> Yes, I would like updates on future FBLA activities.</td></tr> ... <?php ... $activities = (int)$_POST['activities']; ... ?> Using (int) casts the value to the integer type. (It forces it to be a number). If the checkbox is selected, the value passed will be '1'. If the checkbox is not selected, the value is not passed at all (ie, isset($_POST['activities']) == false) (int) '1' == 1 and (int) null == 0 @timmah1 You missed an equals sign in your IF statement.
  13. Er, there seems to be a misunderstanding. That pseudo-code wasn't meant to be used as is. Where it says "getRow()", your actually supposed to fetch the row with mysql_fetch_assoc (or similar). this part: $_POST['id'] = array( '1' => '1', '2' => '1', '3' => '1', '4' => '1', '5' => '1' ); is not supposed to be used at all. It is just an explanation of what the data looks like, after the user submits the form. Before I can offer any real code, I need to know 2 things: 1) What is the error ? 2) is this the flow that the user takes ? i) User fills in form at takeaction.html ii) Form submits to congress.php iii) congress.php generates a form which submits to sendmail.php If that is incorrect, please describe what is happening.
  14. If you name the checkboxes like so: <input type="checkbox" name="id[<?php echo $id; ?>]" value="1" /> EX: <input type="checkbox" name="id[1]" value="1" /> Mike <br /> <input type="checkbox" name="id[2]" value="1" /> John <br /> <input type="checkbox" name="id[3]" value="1" /> George <br /> <input type="checkbox" name="id[4]" value="1" /> Jane <br /> <input type="checkbox" name="id[5]" value="1" /> Sarah <br /> once submitted, your $_POST data will look like this: <?php $_POST['id'] = array( '1' => '1', '2' => '1', '3' => '1', '4' => '1', '5' => '1' ); ?> The 1/2/3/4/5 are the IDs of the checkboxes that were selected. You can loop through this data, and send it to each email: (pseudo-code) <?php foreach($_POST['id'] as $id=>$one){ //SQL query("select email from __ where ID = $id"); $email = getRow(); mail($email, ..... ); } ?>
  15. Export your excel data as a CSV file. Create your database with phpmyadmin to match your excel file. Use phpmyadmins import feature to copy your data from the exported CSV file to your database. Yeah I guess you are.
  16. That just means your missing quotes in the SQL. Add some single quotes: $sql = "insert into table_name values ('". implode("','", $arr) ."')"; Since they not obviously different/hard to see, I added single quotes ' in the implode, and before/after the VALUES() portion of the SQL.
  17. The problem is the SQL. (assuming usrID is the primarykey) SELECT * FROM `tblUsers` WHERE usrID = 1 and 2 and 3 That will only return 1 row. Try $pname = $_POST['players']; // Get The Form Values $new =implode(', ',$pname); $sql = "SELECT * FROM `tblUsers` WHERE usrID IN (" . $new . ")";
  18. Theres no easy way. If you are not storing these cities in a database, at least make a variable to hold them all: $cities = array( 'city1', 'city2', 'city3' /// etc ); Then you can loop through them all and decide to select one, or not. $users_city = "city3"; $html = array(); foreach($cities as $city){ if($users_city == $city){ $html[] = "<option selected=\"selected\" value=\"$city\">$city</option>"; }else{ $html[] = "<option value=\"$city\">$city</option>"; } } echo "<select>" . implode("\n", $html) . "</select>"; Edit: Also forgot to mention another method, which I do not recommend. Simply take your list, and add this bit of javascript. It works for most browsers. <select id="theSelectID"> <option value="city1">city1</option> <option value="city2">city2</option> <option value="city3">city3</option> <option value="city4">city4</option> <option value="city5">city5</option> upto <option value="city50">city50</option> </select> <script> document.getElementById('theSelectID').value = '<?php echo $theUsersCity; ?>'; </script>
  19. SELECT * FROM db WHERE `date` BETWEEN UNIX_TIMESTAMP('2008-06-01 00:00:00') AND UNIX_TIMESTAMP(NOW())
  20. When you say window.location = 'etc'; your navigating away from your page, meaning your current page might not load completely, meaning that window.onload never gets triggered.
  21. If you don't want to use php/mysql, there's not a whole lot that can be done. You could use perl/asp/python/etc... but you can't use just html. I suggest you do some more research on web technologies before attempting anything.
  22. Use include(); to put your anchor at the bottom of a page. We can't be more specific unless you are as well.
  23. Please be more specific. Do you want to do this with MySQL or something? Just connect to site1 (however you chose to) and do what you would normally do to update it.
  24. <?php $num = date("t"); //number of days in the month. $firstDayTime= mktime(0,0,0, date('n'), 1, date('Y')); // First day of the month $lastDayTime= mktime(0,0,0, date('n'), $num, date('Y')); // Last day of the month ?>
  25. Its pretty hard for anything computer related to 'sense' anything. Use math instead. Take todays date for example, May 7th, 2008 could represent 1. Then in your scrip figure out how many days past May 7th it is, and use that as the index. If you only have a certain amount of images, for example, 10, you can use modulus (%) to loop through them with the same logic. ex: 1 % 10 = 1 2 % 10 = 2 3 % 10 = 3 etc... 10 % 10 = 0 11 % 10 = 1 12 % 10 = 2 13 % 10 = 3 etc.. 54 % 10 = 4
×
×
  • 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.