Jump to content

scraptoft

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

scraptoft's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. utexas_pjm I have been trying to solve this for days and you have helped me within 10 minutes - I can't thank you enough for your generous support. The way you have broke it down using several lines has also made me actually fully understand the code I was working with - it's not guess work anymore! I was getting too far ahead of myself - the WHERE clause wasn't nercersarry for what I wanted so I just removed it and it's working great. Thank you.
  2. You are right on it utexas_pjm your input was a massive help. I have checked and every record in 'content' has a PARENT_ID. I tried replacing the '$parent_ID' with a parent_id number i.e '20' and it worked. I can't work out why it isn't working when I use the variable '$parent_id'.  What I am trying to do is get the last 10 records in by ID ASCENDING order. ps. sorry phpfreaks I just realised there is a MYSQL specific forum so this could be in the wrong place.
  3. This is my first time working with MYSQL JOINS. I have two tables [u]Content:[/u] title|parent_id [u]Categories:[/u] category_id|title I want to query CONTENT and get TITLE and PARENT_ID. I then want to query the CATEGORIES table and get the TITLE where category_id = parent_id. Heres what I have: [quote]$join=mysql_query("SELECT t1.title, t2.title FROM content as t1 join categories as t2 on t1.parent_id = t2.category_id where t2.category_id = $parent_id"); while($row=mysql_fetch_array($join)){ extract($row); }[/quote] The error: [quote]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in join.php on line 7 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 '' at line 1[/quote]
  4. I have a dynamic php + mysql page. Does anyone know the code to show how long the page took to load? i.e Total time taken to generate page: 0.08seconds. Cheers.
  5. Do you want to pass $myvar through the hyperlink? [code]<?php   $myvar = 2;     echo "<a href=\"file2.php\" >";       echo "<a href="file2.php?myvar=value"><img src=\"my_img.gif\" border=\"1\"></a>";   echo "</a>";[/code]
  6. I'm getting a Parse error: syntax error, unexpected $end. But can't find any curly brackets that havn't been closed. I'm hoping its only somthing minor.
  7. Thanks for the link, here is what I have came up with so far: [code]    //"convert" the image to jpg     $maxwidth = 100;     $maxheight = 400;     if (($width>$maxwidth) OR ($height>$maxheight)) (         $image_jpg = imagecreatetruecolor($width, $height);     imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0,                      $maxwidth, $maxheight, $maxwidth, $maxheight);     )else (     $image_jpg = imagecreatetruecolor($width, $height);     imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0,                      $width, $height, $width, $height);)                          imagejpeg($image_jpg, $newfilename);     imagedestroy($image_old);     imagedestroy($image_jpg);   }[/code] I'm getting a Parse error: syntax error, unexpected ';' . Anyone see why?
  8. Hi, Can I change my thumbnail creator script to resize the thumbnails to [b]exact sizes[/b]? As it is it creates the thumbnail by percentage of width and height(?). Here is my code: [code]   //get the dimensions for the thumbnail   $thumb_width = $width * 0.30;   $thumb_height = $height * 0.30;   //create the thumbnail   $largeimage = imagecreatefromjpeg($newfilename);   $thumb = imagecreatetruecolor($thumb_width, $thumb_height);   imagecopyresampled($thumb, $largeimage, 0, 0, 0, 0,                     $thumb_width, $thumb_height, $width, $height);   imagejpeg($thumb, $newthumbname);   imagedestroy($largeimage);   imagedestroy($thumb); [/code] Any suggestions on how to do this? I would like all of my thumbnails creating to 55x55 pixels. Cheers
  9. Cheers mate, i'm finding that post very helpful. I'm 80% to the way I want it, another hour or so and it should be working great. Cheers guys
  10. [b]b[/b]u[b]m[/b]p Anyone can shed some more light on this problem?
  11. I'm still trying to learn PHP but could do with this project finished (it doesn't have to be perfect) so I can get onto studying the language more. Could you give me a few pointers on how I could get away with it. p.s thanks for the tutorial I will deffinatly read it more indepth in the morning.
  12. My category table is like so. Name [name of category or subcategory] parent_category [if its a subcategory the parent name is here] level ['1','2','3'] [different levels to show on each page] After writing this out, i'm starting to think I need to make changes to my table. Or can I get away with it this way? Cheers for your fast reply.
  13. I am trying to create a navigation bar which will echo all of the categories in the database. I want the navigation bar to show like below: Category1 -subcategory -subcategory -subcategory Category2 -subcategory -subcategory Category3 -subcategory -subcategory -subcategory -subcategory Heres my code to query Category: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$query_category = "SELECT name FROM webstructure where level = '2'"; $result_level = mysql_query($query_category) or die("Invalid query: " . mysql_error()); while ($row=mysql_fetch_array($result_lcategory2)) { $name = $row['name'];[/quote] This echos like: Category1 Category2 Category3 I cannot figure out how to echo the correct [b]Subcategory[/b] underneath it's speficific [b]Category[/b]. Does anyone have any ideas how to do this, or what functions to use? Thankyou for your time
  14. Mate it works like an absolute dream, thankyou so much for the time you have spent on this. I'm so happy you converted my code too (well kinda, more like changed) from the $rows[number] to $row[name of field] I understand it a whole lot better now. Cheers again!
  15. Just tested it, unfortunatly it didn't ouput anything; just a blank page. I have just been reading about parentheses, could it possibly have anything to do with this? Instead of using echo() use print()? Any more comments are very very welcome.
×
×
  • 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.