Jump to content

globetrottingmike

Members
  • Posts

    18
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

globetrottingmike's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you I will give it a go later and let you know how I get on.
  2. Thanks for your assistance with this. Would my code becomes as follows? <?php // connect database $dbc = mysql_connect("localhost", "###", "###"); // select database mysql_select_db("artbyiyu_art", $dbc); if(isset($_POST)) { //echo $_POST['name']; $fileName = $_POST['name']; $time = time(); mysql_query("INSERT INTO uploadify3(filename, filedate, category) VALUES('$fileName', '$time', '$category')"); $category = mysql_real_escape_string($_GET['cat']); $inserted_id = mysql_insert_id($dbc); if($inserted_id > 0) { // if success echo "uploaded file: " . $fileName; } } ?>
  3. Hi all, Here is my existing code for inserting a new entry into a MySQL table. What I would like to do is be abel to add the 'ccategory' from a URL parameter - such as www.mysite.com/add_image.php?cat=3 . Can you help me edit my code below to make this work. Thanks, Mike --------------------------------------------------------------- <?php // connect database $dbc = mysql_connect("localhost", "###", "###"); // select database mysql_select_db("artbyiyu_art", $dbc); if(isset($_POST)) { //echo $_POST['name']; $fileName = $_POST['name']; $time = time(); mysql_query("INSERT INTO uploadify3(filename, filedate, category) VALUES('$fileName', '$time', '$category')"); $inserted_id = mysql_insert_id($dbc); if($inserted_id > 0) { // if success echo "uploaded file: " . $fileName; } } ?>
  4. OK, I have just tried: <?php mysql_select_db($database_FCK2, $FCK2); $query_rsort_desc = "SELECT numbers.id, numbers.`number` FROM numbers ORDER BY numbers.id DESC LIMIT 10"; $rsort_desc = mysql_query($query_rsort_desc, $FCK2) or die(mysql_error()); $row_rsort_desc = mysql_fetch_assoc($rsort_desc); $totalRows_rsort_desc = mysql_num_rows($rsort_desc); $Ids = array(); while ($row = mysql_fetch_assoc($idResult)) { $postIds[] = $row['id']; } $Ids = implode(", ", $Ids); mysql_select_db($database_FCK2, $FCK2); $query_rsort_asc = "SELECT numbers.id, numbers.`number` FROM numbers WHERE id IN({$Ids}) ORDER BY numbers.id ASC"; $rsort_asc = mysql_query($query_rsort_asc, $FCK2) or die(mysql_error()); $row_rsort_asc = mysql_fetch_assoc($rsort_asc); $totalRows_rsort_asc = mysql_num_rows($rsort_asc); ?> However, returned: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/thefood/public_html/rsort2.php on line 43 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY numbers.id ASC' at line 1 Any ideas??
  5. Can you give me a little guidance on this. How would I go about linking the two queries?
  6. Tried: SELECT forum_posts.id_msg, forum_posts.date_msg, forum_posts.content_msg FROM forum_posts WHERE id_msg IN(SELECT id_msg FROM fourm_posts ORDER BY date_msg DESC LIMIT 10) ORDER BY forum_posts.id_msg ASC And it showed error: 'This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' '
  7. using ASC sounds logical, but would that just show the first 10 results?
  8. Is it possible to reverse sort results in a dynamic table? I want to show the last 10 posts on a forum topic, so would normally create a recordset query with 'LIMIT 10 DESC' in it. When the results show in a table it will show the newest post at the top: 85 84 83 .. .. 76 74 however, I would like to show the last 10 posts, but with the most recent a the bottom of the table: 74 75 .. .. 83 74 85 (74-85 being the most recent 10 posts) Thanks for any suggestions in advance
  9. Would it be something like this in php: <?php function convert_tz ($date_str, $tz) ?> <?php echo convert_tz('2008-08-08 08:08:08', +2) only it does not seem to work.
  10. That looks great for the database, I am guessing that would change all dates in the database? How can I use in my php page. One of my members may be located in Paris, while another member may be located in New York, while another member in Sydney. They all need to see the timestamp stored in the database +or- their time difference from GMT.
  11. Hi, I have developed a php/mysql application which I want my members to be able to see say forum posts in their local time zone. Their time zone info would be stored in the members table of the database, so a member living in Paris would have a +1 hr time zone difference stored in their profile from my server in London. I have worked out from loads of searching that the following piece of script can adjust the current time (NOW) by adding or subtracting what is stored in that database field: function getLocalTime($tm, $offset){ return ($tm - date("Z", $tm)) + (3600 * $offset); } // get current local time in bangkok echo date("H:i:s d-m-y", getLocalTime(mktime(), $row_rs_timezone['difference'])). "<br>"; And I know that this line of code shows the date of the entry from the database data: <?php echo date ("d M Y",strtotime($row_wall ['wall_date'])); ?> How can I know marry the two up? I want to retrieve the date and time from the database item, say the forum post, and then use the first script I showed to calculate the difference? Many thanks in advance
  12. Hi, I have developed a php/mysql application which I want my members to be able to see say forum posts in their local time zone. Their time zone info would be stored in the members table of the database, so a member living in Paris would have a +1 hr time zone difference stored in their profile from my server in London. I have worked out from loads of searching that the following piece of script can adjust the current time (NOW) by adding or subtracting what is stored in that database field: function getLocalTime($tm, $offset){ return ($tm - date("Z", $tm)) + (3600 * $offset); } // get current local time in bangkok echo date("H:i:s d-m-y", getLocalTime(mktime(), $row_rs_timezone['difference'])). "<br>"; And I know that this line of code shows the date of the entry from the database data: <?php echo date ("d M Y",strtotime($row_wall ['wall_date'])); ?> How can I know marry the two up? I want to retrieve the date and time from the database item, say the forum post, and then use the first script I showed to calculate the difference? Many thanks in advance
  13. http://www.phpfreaks.com/tutorial/basic-pagination <-this one
  14. Thanks Chronister for your reply. What I need to do is be able to go to a paginated page that is worked out by the record_id field. PunBB use the following piece of code in their viewtopic.php page to determine the page number is such a way. // If a post ID is specified we determine topic ID and page number so we can redirect to the correct message if ($pid) { $result = $db->query('SELECT topic_id FROM '.$db->prefix.'posts WHERE id='.$pid) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); if (!$db->num_rows($result)) message($lang_common['Bad request']); $id = $db->result($result); // Determine on what page the post is located (depending on $pun_user['disp_posts']) $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$id.' ORDER BY posted') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); $num_posts = $db->num_rows($result); for ($i = 0; $i < $num_posts; ++$i) { $cur_id = $db->result($result, $i); if ($cur_id == $pid) break; } ++$i; // we started at 0 $_GET['p'] = ceil($i / $pun_user['disp_posts']); } The would give a URL like www.mysite.com/somepage.php?id=1233#id1234 Do you know how this would integrate with your code? Let me know if you would like a clearer explanation.
  15. Thanks BlueSky for your quick response, however what I need to know is how to set up pagination for a hyperlink where I don't know which page number that forum post is on. Below is a PunBB viewtopic.php extract which does this: // If a post ID is specified we determine topic ID and page number so we can redirect to the correct message if ($pid) { $result = $db->query('SELECT topic_id FROM '.$db->prefix.'posts WHERE id='.$pid) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); if (!$db->num_rows($result)) message($lang_common['Bad request']); $id = $db->result($result); // Determine on what page the post is located (depending on $pun_user['disp_posts']) $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$id.' ORDER BY posted') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); $num_posts = $db->num_rows($result); for ($i = 0; $i < $num_posts; ++$i) { $cur_id = $db->result($result, $i); if ($cur_id == $pid) break; } ++$i; // we started at 0 $_GET['p'] = ceil($i / $pun_user['disp_posts']); } Does anyone understand this and would be wiling to help me integrate it into my pagination solution? Thanks 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.