Jump to content

jakeoh

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Everything posted by jakeoh

  1. Thanks. However I am talking about a user selected "Rank" column or something similar, not the user ID.
  2. Hi, I am doing a simple CMS application for someone. On one page, the members of an association are listed. I want to give the CMS user the possibility to add and remove persons from the table, and to decide the order in which they are displayed (not alphabetically). Now my first idea is to create a "rank" column in the table, and then to order by this column when making the query. My question is: is it possible to have the user select the rank from a drop-down list, and then to update all other values in the column to a new value so that every rank is unique? For example, if the user selects "3" for "John Smith", then the current person with the "3" value will be bumped to 4, "4" bumped to 5, etc.? What would be the best way to achieve this? Thanks!
  3. I made small adjustments so that it fits my code but all is well now. Thanks a lot!
  4. Thanks Samshel, it worked perfectly. Now just another thing... how can I append the year in my table, for every year (March 2009, April 2009, etc., January 2010, February 2010, etc.) Thanks a lot, again.
  5. I understand your technique. However I'm not sure how to code it. How can the foreach start on the current month?
  6. I have an two-level array that contains, at the first level, a month of the year; the second level contains events held that month (name, description, start date, end date). I want to display this array in a table (events to come). The code I am using right now is this: <table class="calendrier"> <?php foreach($month_list as $month) { echo "<tr><td class='calendrier_mois' colspan='3'><h3>".$month['month_name']." </h3></td></tr>"; echo "<tr class='calendrier_head'>"; echo "<td class='calendrier_date'>Dates</td>"; echo "<td class='calendrier_even'>Événements</td>"; echo "<td class='calendrier_lieu'>Lieu</td>"; echo "</tr><tr>"; foreach($month['event_list'] as $event) { echo "<td class='calendrier_01'>".$event['event_startdate']."</td>"; echo "<td class='calendrier_02'>".$event['event_description']."</td>"; echo "<td class='calendrier_03'>".$event['event_location']."</td>"; echo "</tr>"; } } ?> </table> This is all fine, but I want to start with the current month; my array is ordered from January to December, so they are obviously ordered this way presently. How can I use PHP to start with the current month, and then cycle through the array and come back to January after December? Hope it's clear. Jake
  7. Hi, Thanks for your answer. I would obviously like to ignore IE6, but then again there are still too many (lazy) persons that use it, so I cannot just leave it that way. If someone can find a way to tweak the page so that it looks ok in IE6, I'll be delighted. What do you mean the log in doesn't work? It's currently being developed, so it's normal it's not really functional yet, but I am curious as to what you are referring to.
  8. Hi all, When I look at the following page: www.beta.mespetits.com The login bar underneath the navigation looks good in FF and IE7, but there is a problem for which I cannot find a solution in IE6. Does anyone has an idea what the problem may be? (Well the problem seems to be IE6, but is there a tweak to fix this?)
  9. 1) Thanks! 2) I have no problem doing that (one table per category) as one of my main goals is to practice designing databases... So using that solution, what tables would be required and which relation should be made? I guess I would create a Clothes table, that would relate to the Categories table through cat_id, and then in that table (Clothes) I would cover all possibilities (Women/Men/Unisex - different sizes)? But where is the specific information about, say, that specific Large sweater for Men is kept? In a new Category-Clothes table? 3) Great, thanks.
  10. Hi, I want to design a little classified ads website for fun. Now I am thinking at how my DB should be structured. So far I have this (I omitted certain fields that are not relevant for my question): Ad table ad_id ad_title ad_description ad_price ad_startdate ad_enddate Categories table cat_id cat_name cat_description Ad-Categories table ad_id cat_id User table user_id user_name ... Ad-User table ad_id user_id My questions are: 1. Does it seem like a good structure so far? It's my first time designing such a database, so I wouldn't know. 2. If a user posts an ad for the clothes category, he would have to select if the clothes are for men or women, and a specific size (say S, M, L, XL). Now where would that go in the database? In a new table? In the Ad table? In the Categories table? 3. What is the best datatype for the "Price" column? Is it decimal, or should I just use an integer and use php to deal with the decimals (for cents)? Thanks in advance!
  11. Sorry, I somehow thought timestamp was calculated in milliseconds. Using 604800 instead of 604800000 solved it.
  12. Hi, I want to have mySQL return users that went to my site in the last 7 days. When a user logs in or uses the website, the 'timestamp' column in the database is updated with the current timestamp. The MySQL query I have so far to get the list of active users in the past 7 days is as follows: $q = "SELECT username, first_name, last_name FROM ".TBL_USERS." WHERE timestamp > (UNIX_TIMESTAMP() - '604800000') ORDER BY timestamp DESC,username"; This query however get the users that were active more than 7 days ago. What is wrong with it? How would you build your query?
  13. Noob here, obviously. I have a database of users, each with an email address. I would like to get a string with every address followed by a comma. My SQL query will go "SELECT email FROM users", but how do I format the results so that I have a nice string with all addresses separated with a comma?
  14. I tried with the meta tags, but to no avail; it kept on displaying the ? in Firefox and the box in Explorer. However this solved the problem: setlocale(LC_ALL, 'fr_FR@euro'); $header = strftime('%B', mktime(0,0,0,$this->month,1,$this->year)).' '.$this->year; $header = htmlentities($header);
  15. Hi, I have the following code to display the name of the month in French: setlocale(LC_ALL, 'fr_FR@euro'); $header = strftime('%B', mktime(0,0,0,$this->month,1,$this->year)).' '.$this->year; This works great, but the accentuated characters (é, û) are replaced with ? in Firefox and a square in IE. How do I get around this so that it displays the correct characters?
  16. I tried a couple of things but I'm way over my head. I guess I should use the onscroll function to monitor the use of the scrollbar... but then what do I do? How can I do the following: onscroll=stop the setInterval of the showdata() function, and then somehow set it again after a certain time or when the scroll is not used anymore. Help!
  17. This seems to work now: www.shlak.ca/test_table_2.htm Needed to create an additionnal style: <html> <head> <title>Test Table IE7</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> td { background-color: #4f6621; color: #ffffe3; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; text-align:center; width:100; } .overrideWidth{ width:300; } </style> </head> <body> <table border="1"> <tr> <td>Hello</td> <td colspan='3' class='overrideWidth'>Hello</td> <td>Hello</td> </tr> <tr> <td>Hello</td> <td>Hello</td> <td>Hello</td> <td>Hello</td> <td>Hello</td> </tr> </table> </body> </html> However it is still not centered perfectly in IE7. But at least it tries now.
  18. Doesn't seem to work... it looks like IE7 effectively centers the month but forgets that it should center it at the center of the 3 merged cells (colspan='3')... It just centers it in the middle of the first column. Look at this new even simpler example: http://www.shlak.ca/test_table.htm This is caused by the "width:100;" attribute of the td. If I remove this line, it is centered OK. As I see it, FF and IE6 override this attribute when they see "colspan='3'", but not IE7. Now, how do I fix this?
  19. Hi, No idea what I'm doing wrong, but look at this calendar: http://www.shlak.ca/test_calendar.htm (There are broken links and functions, since I only pasted the relevant code on the test page) Can anyone explain why the name of the month in the header is not centered when using IE7? It works fine with FF and IE6. <html> <head> <title>Test Calendar</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> .calendar { /** configure the width **/ width:510px; background-color: #ffffe3; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; margin:0px; padding:0px; text-align:center; } /*Jours de la semaine*/ .calendar th { background-color: #4f6621; color: #ffffe3; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; text-align:center; width: 58px; height: 19px; padding: 4px; } .calendar .day_box { background-color: #ddddbd; color: #35490b; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; /*border: 1px solid #000000;*/ text-align:left; width: 62px; height: 62px; padding: 4px; background-image: url(Images/calendar_box.gif); } .calendar .header { background-color: #ffffe3; font-weight: bold; height: 24px; color: #35490b; text-align: center; } .calendar .footer { background-color: #4f6621; font-weight: bold; font-size:10px; color: #ffffe3; width:100%; } .calendar td { width: 22px; height: 20px; text-align: center; font-size:0.9em; /*padding: 1px;*/ } .calendar .today { background-color: #FAD2DA; color: #35490b; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; text-align:left; width: 62px; height: 62px; padding: 4px; background-image: url(Images/calendar_today.gif); } .calendar .link { background-color: #D4C9EF; color: #35490b; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; text-align:left; width: 62px; height: 62px; padding: 4px; background-image: url(Images/calendar_birthday.gif); } .calendar .birthday { float:right; font-size: 8px; } .calendar a, .calendar a:link, .calendar a:hover { font-weight: bold; text-decoration: underline; color: #000000; } .calendar a.headerNav, .calendar a:link.headerNav, .calendar a:hover.headerNav { background-color: #ffffe3; color: #35490b; } .calendar a.footerNav, .calendar a:link.footerNav, .calendar a:hover.footerNav { width: 100%; background-color: #4f6621; color: #ffffe3; } </style> </head> <body> <div id='quickCalender'><table cellspacing='0' cellpadding='0' class='calendar'> <tr> <th class='header'> <a href="javascript:;" onclick="displayQCalendar('11','2006')" class='headerNav' title='Prev Year'><<</a></th> <th class='header'> <a href="javascript:;" onclick="displayQCalendar('10','2007')" class='headerNav' title='Prev Month'><</a></th> <th colspan='3' class='header' >Nov 2007</th> <th class='header'><a href="javascript:;" onclick="displayQCalendar('12','2007')" class='headerNav' title='Next Month'>></a> </th> <th class='header'> <a href="javascript:;" onclick="displayQCalendar('11','2008')" class='headerNav' title='Next Year'>>></a></th> </tr><tr><th>Dim</th><th>Lun</th><th>Mar</th><th>Mer</th><th>Jeu</th><th>Ven</th><th>Sam</th></tr><tr><td><div class='day_box'></div></td><td><div class='day_box'></div></td><td><div class='day_box'></div></td><td><div class='day_box'></div></td><td><div class='link'>1<br><a href='userinfo.php?user=Parara\'><img class='birthday' src='Images/cake.gif' width='39' height='35' border='0' title='Anniversaire de Parara!!!'></a></div></td><td><div class='link'>2<br><a href='userinfo.php?user=Robbie\'><img class='birthday' src='Images/cake.gif' width='39' height='35' border='0' title='Anniversaire de Robbie!!!'></a></div></td><td><div class='day_box'>3</div></td></tr><tr><td><div class='day_box'>4</div></td><td><div class='link'>5<br><a href='userinfo.php?user=Jokolito\'><img class='birthday' src='Images/cake.gif' width='39' height='35' border='0' title='Anniversaire de Jokolito!!!'></a></div></td><td><div class='today'>6</div></td><td><div class='day_box'>7</div></td><td><div class='day_box'>8</div></td><td><div class='day_box'>9</div></td><td><div class='day_box'>10</div></td></tr><tr><td><div class='day_box'>11</div></td><td><div class='day_box'>12</div></td><td><div class='day_box'>13</div></td><td><div class='day_box'>14</div></td><td><div class='day_box'>15</div></td><td><div class='day_box'>16</div></td><td><div class='link'>17<br><a href='userinfo.php?user=papou\'><img class='birthday' src='Images/cake.gif' width='39' height='35' border='0' title='Anniversaire de papou!!!'></a></div></td></tr><tr><td><div class='day_box'>18</div></td><td><div class='day_box'>19</div></td><td><div class='day_box'>20</div></td><td><div class='day_box'>21</div></td><td><div class='day_box'>22</div></td><td><div class='day_box'>23</div></td><td><div class='day_box'>24</div></td></tr><tr><td><div class='day_box'>25</div></td><td><div class='day_box'>26</div></td><td><div class='day_box'>27</div></td><td><div class='link'>28<br><a href='userinfo.php?user=Patouille\'><img class='birthday' src='Images/cake.gif' width='39' height='35' border='0' title='Anniversaire de Patouille!!!'></a></div></td><td><div class='link'>29<br><a href='userinfo.php?user=ggrasdur\'><img class='birthday' src='Images/cake.gif' width='39' height='35' border='0' title='Anniversaire de ggrasdur!!!'></a></div></td><td><div class='day_box'>30</div></td><td><div class='day_box'></div></td></tr><tr><td colspan='7' class='footer'><a href="javascript:;" onclick="displayQCalendar('11','2007')" class='footerNav'>Nous sommes aujourd'hui le 6 Nov 2007</a></td></tr></table></div></div> </body> </html>
  20. I added a shoutbox to my site; messages are displayed in a <div> section and refreshed every couple of seconds. Since there can be lots of messages in this section, scrollbars are used. The problem is, when someone wants to scroll through the messages, he is always brought back to the top by the funcrion that refreshes the shoutbox. Here's the code in the .js file: function showData() { htmlRequest = ajaxFunction(); if (htmlRequest==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request"); return; } htmlRequest.onreadystatechange = function(){ if(htmlRequest.readyState == 4){ document.getElementById("shoutarea").innerHTML = htmlRequest.responseText; } } htmlRequest.open("GET", "outputinfo.php", true); htmlRequest.send(null); } showData(); setInterval("showData()",5000); And here's the code in the php file: <? include("Include/shoutbox_connect.php"); open_connection(); $shout_query = "SELECT * FROM shoutbox ORDER BY `date` DESC LIMIT 10"; $shout_result = mysql_query($shout_query); $count = 0; echo '<div style="border:1px #000000 solid; width:200; height:278px; overflow:auto;">'; while($shout_row = mysql_fetch_array($shout_result)) { $shouter_name = $shout_row['username']; $shout_content = $shout_row['content']; $shout_content = stripslashes($shout_content); $shout_date = $shout_row['date']; // $dday = substr($shout_date, 8, 2); $dday = strftime('%d/%m/%y', strtotime($shout_date)); $dtime = strftime('%H:%M:%S', strtotime($shout_date)); $dmonth = substr($shout_date, 5, 2); $dyear = substr($shout_date, 0, 4); $dhour = substr($shoutdate, 11,2); $dminute = substr($shoutdate, 14,2); if(($count % 2) != 0) { echo "<p class='shoutboxCssOdd'><b>$shouter_name</b> said, on $dday &agrave $dtime: <br> $shout_content </p>"; } else { echo "<p class='shoutboxCssEven'><b>$shouter_name</b> said, on $dday &agrave $dtime: <br> $shout_content </p>"; } $count++; } ?> </div> Anyone has a hint on how I can prevent this?
  21. Hi, I have a section on my page where I want to display the avatar and name of users currently logged on. The following code works perfect, but I want to format it a certain way and do not know how; in this section I would like to display each entry (avatar + username) in a 2 column table: User #1 User #2 User #3 User #4 Here's the code I have right now, which will display the users one after the other in a single column table: elseif($num_rows > 0){ /* Display active users, with link to their info */ echo "<table width=\"213\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">\n"; echo "<tr><td><font size=\"2\">\n"; for($i=0; $i<$num_rows; $i++){ $uname = mysql_result($result,$i,"username"); $avatarQuery = "SELECT avatarID, last_name, first_name FROM ".TBL_USERS." WHERE username = '$uname'"; $resultAvatar = $database->query($avatarQuery); $uAvatar = mysql_result($resultAvatar, 0); $first_name = mysql_result($resultAvatar, 0, "first_name"); $last_name = mysql_result($resultAvatar, 0, "last_name"); $initial = $last_name[0]; echo '<img src="get_avatar.php?pid='.$uAvatar.'"width="60" height="60">'; echo "<br>"; echo "<a href=\"userinfo.php?user=$uname\">$first_name $initial</a>"; echo "<br>"; echo "<br>"; } echo "</font></td></tr></table><br>\n"; } How can I format the info in two columns?
  22. Anyone? I messed up the question in the previous post, what I wanted to ask is: How can I make it so that all these comments are contained within a certain height, with scroll bars if necessary?
×
×
  • 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.