Jump to content

golfer

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

golfer's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I currently have a search page on my site that prints the products but it prints the products more than once if its in more than one category I have tried getting distinct item in my SQL. But this doesnt work so im trying an if statement that if there is more than one specific result then to just print this once. I was wondering if anyone had any ideas of how to do this using an if statement I just dont know how to go about just printing the result just once if its greater than 1. The code is below to make it clearer. $searchterm = $_POST['searchterm']; trim ($searchterm); /*check if search term was entered*/ if (!$searchterm){ echo 'Please enter a search term.'; echo $searchterm; } /*add slashes to search term*/ if (!get_magic_quotes_gpc()) { $searchterm = addslashes($searchterm); } /*query the database*/ $query = "SELECT * from (products LEFT JOIN categories_products_link ON products.prod_id = categories_products_link.prod_id) LEFT JOIN categories ON categories_products_link.cat_id = categories.cat_id WHERE prod_title LIKE '%" . $searchterm . "%' ORDER BY cat_title, prod_title"; $result = mysql_query($query); /*number of rows found*/ $num_results = mysql_num_rows($result); echo '<p><h1>Search Results: '.$num_results.'</h1></p><br />'; /*loops through results*/ for ($i=0; $i <$num_results; $i++) { $num_found = $i + 1; $row = mysql_fetch_assoc($result); echo "$num_found. "?><a href="store-<?php echo $row['cat_id'];?>-<?php echo $row['prod_id']; ?>/<?php echo seo_makeSafeURI($row['prod_title']); ?>.html"><strong><?php echo $row['prod_title']; ?></strong></a> <br />
  2. I have been trying to upload videos using the move_uploaded_file function but have come up with a new error which is displayed below. Warning: move_uploaded_file(/home/~unn_s003539/public_html/Sold/uploadsPC45 close up .jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_s003539/public_html/Sold/vidupload.php on line 25 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpUWYU51' to '/home/~unn_s003539/public_html/Sold/uploadsPC45 close up .jpg' in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_s003539/public_html/Sold/vidupload.php on line 25 Error when uploading the video./var/www/vhosts/numyspace.co.uk/httpdocs I don't understand why this error is occuring as the file target I'm using is exactly the same as the one in the ftp file which I have just copied across. My code looks like this: session_start(); include("connection.php"); $target = "/home/~unn_s003539/public_html/Sold/uploads"; $target = $target . basename( $_FILES['video']['name']); $name=$_POST['name']; $email=$_POST['email']; $title=$_POST['title']; $description = $_POST['description']; $pic=($_FILES['video']['name']); $sql="INSERT INTO `videos` (name, date, email, title, description, video) VALUES ('$name','CURDATE()', '$email', '$title', '$description','$pic')" ; $result=mysql_query($sql); if(move_uploaded_file($_FILES['video']['tmp_name'], $target)) { echo "Successful upload of ". basename( $_FILES['video']['name']); } else{ echo "Error when uploading the video."; }. Any Help would be greatly appreciated.
  3. I have been trying to upload videos using the move_uploaded_file function but have come up with a new error which is displayed below. Warning: move_uploaded_file(/home/~unn_s003539/public_html/Sold/uploadsPC45 close up .jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_s003539/public_html/Sold/vidupload.php on line 25 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpUWYU51' to '/home/~unn_s003539/public_html/Sold/uploadsPC45 close up .jpg' in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_s003539/public_html/Sold/vidupload.php on line 25 Error when uploading the video./var/www/vhosts/numyspace.co.uk/httpdocs I don't understand why this error is occuring as the file target I'm using is exactly the same as the one in the ftp file which I have just copied across. My code looks like this: session_start(); include("connection.php"); $target = "/home/~unn_s003539/public_html/Sold/uploads"; $target = $target . basename( $_FILES['video']['name']); $name=$_POST['name']; $email=$_POST['email']; $title=$_POST['title']; $description = $_POST['description']; $pic=($_FILES['video']['name']); $sql="INSERT INTO `videos` (name, date, email, title, description, video) VALUES ('$name','CURDATE()', '$email', '$title', '$description','$pic')" ; $result=mysql_query($sql); if(move_uploaded_file($_FILES['video']['tmp_name'], $target)) { echo "Successful upload of ". basename( $_FILES['video']['name']); } else{ echo "Error when uploading the video."; }. Any Help would be greatly appreciated.
  4. The Sql is fine and does exactly what I need. The error is in the code I have changed to make the title only appear once. I will continue to change things to see what works. Select * from (products LEFT JOIN categories_products_link ON products.prod_id = categories_products_link.prod_id) LEFT JOIN categories ON categories_products_link.cat_id = categories.cat_id;
  5. On my website it just says database query error. But have run the query straight into the database and it works fine. So am unsure of what exactly is wrong with the code.
  6. That makes sense thankyou. I am however getting an error from my updated code. For the variable $current_category can you call this anything? <?php $current_category='cat'; while($row = $db->query($stuff)) { if($current_category != $row['cat_title']){ ?> <li><a href="store-<?php echo $row['cat_id']; ?>/<?php echo seo_makeSafeURI($row['cat_title']); ?>.html"><strong><?php echo stripslashes(htmlentities($row['cat_title'])); ?></strong></a></li> <?php $current_category=$row['cat_title']; ?> <li><a href="store-<?php echo $row['cat_id']; ?>-<?php echo $row['prod_id']; ?>/<?php echo seo_makeSafeURI($row['prod_title']); ?>.html"><?php echo stripslashes(htmlentities($row['prod_title'])); ?></a></li> <?php } }?>
  7. I tried Group BY cat_title but this just brought back the category and only one product that was in that category so tried GROUP_BY cat_title, prod_title just brought back the same result as before.
  8. I currently have a problem where I'm trying to list alot of products with the category heading only being returned once and then the long list of products within that category being listed. For Example Football boots Nike Addidas Puma etc Whereas at the moment I'm getting. Football boots Nike Football boots Addidas Football boots Puma My current code for this is as follows. <?php while($row = $db->fetchrow($stuff)) { ?> <li><a href="store-<?php echo $row['cat_id']; ?>/<?php echo seo_makeSafeURI($row['cat_title']); ?>.html"><strong><?php echo stripslashes(htmlentities($row['cat_title'])); ?></strong></a></li> <li><a href="store-<?php echo $row['cat_id']; ?>-<?php echo $row['prod_id']; ?>/<?php echo seo_makeSafeURI($row['prod_title']); ?>.html"><?php echo stripslashes(htmlentities($row['prod_title'])); ?></a></li> <?php } ?> Any help would be much appreciated.
×
×
  • 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.