Jump to content

kikilahooch

Members
  • Posts

    72
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kikilahooch's Achievements

Member

Member (2/5)

0

Reputation

  1. I have a search facility on my page so that users can search for products. There are a lot of products on my site and searchs can return up to 100 results some time. I want to be able to limit the amount of results to 10 per page. The code below does this but when I click on display next results it just displays the same ones back again. Would be really grateful if someone could point out what needs to be modified [code] <?php $host=   // Get the search variable from URL   $var = @$_GET['q'] ;   $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "")   {   echo "<p><b>Please enter a search...<B></p>";   exit;   } // check for a search parameter if (!isset($var))   {   echo "<p><b>We dont seem to have a search parameter!<b></p>";   exit;   } include "db.php"; $query = "select * from product where dept like \"%$trimmed%\" OR type like \"%$trimmed%\" OR prodName like \"%$trimmed%\" OR shopName like \"%$trimmed%\" OR brand like \"%$trimmed%\" order by dept, type, prodName, shopName, brand"; //db $result = mysql_query($query,$conn) or die(mysql_error()); //get the number of rows in the result set; should be 1 if a match if (mysql_num_rows($result) >= 1) { //if authorized, get the values of name, surname $image = mysql_result($result, 0, 'image'); $prodName = mysql_result($result, 0, 'prodName'); $price = mysql_result($result, 0, 'price'); $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0)   {   echo "<h4>Results</h4>";   echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero results</p>"; // google echo "<p><a href=\"http://www.google.com/search?q="   . $trimmed . "\" target=\"_blank\" title=\"Look up   " . $trimmed . " on Google\">Click here</a> to try the   search on google</p>";   } // next determine if s has been passed to script, if not use 0   if (empty($s)) {   $s=0;   } // get results   $query .= " limit $s,$limit";   $result = mysql_query($query) or die("Couldn't execute query"); // begin to show results set echo' <h1><font color="#FF6600"><center>SEARCH RESULTS</center></font></h1> <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8"> <tr> <td align="left" bgcolor="#2696b8"><center><font color="#FFFFFF"><b>Image</b></center></td> <td align="left" bgcolor="#2696b8"><center><font color="#FFFFFF"><b>Product Name</b></td> <td align="left" bgcolor="#2696b8"><center><font color="#FFFFFF"><b>Price</b></td> <td align="left" bgcolor="#2696b8"><center><font color="#FFFFFF"><b>Buy</b></td> </tr>'; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo'<tr> <td align="center" width="150" height="200"><img src="http://snet.wit.ie/~ciaracousins/clothes/' . $row['image'] . '"> <td align="center"><b>'.$row['prodName'].'</td></b> <td align="center"><b>€'.$row['price'].'</td></b> <td align="center"><form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit"></td> </tr>'; } echo'</table>'; } $count = 1 + $s ; // now you can display the results returned   while ($row= mysql_fetch_array($result)) {   $title = $row["1st_field"];   echo "$count.)&nbsp;$title" ;   $count++ ;   } $currPage = (($s/$limit) + 1); //break before paging   echo "<br />";   // next we need to do the links to other results   if ($s>=1) { // bypass PREV link if s is 0   $prevs=($s-$limit);   print "&nbsp;<a href=\"$PHP_SELF?s=$prevs&q=$var\">&lt;&lt;   Prev 10</a>&nbsp&nbsp;";   } // calculate number of pages needing links   $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division   if ($numrows%$limit) {   // has remainder so add one page   $pages++;   } // check to see if last page   if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {   // not last page so give NEXT link   $news=$s+$limit;   echo "&nbsp;<a class=orange href=\"$PHP_SELF?s=$news&q=$var\"><b>Next 10 &gt;&gt;</b></a>";   } $a = $s + ($limit) ;   if ($a > $numrows) { $a = $numrows ; }   $b = $s + 1 ;   echo "<p><b>Showing results $b to $a of $numrows</b></p>";   $imageDir = "http://snet.wit.ie/~ciaracousins/clothes/"; $imagePath = $imageDir."".$image; //echo "$query"; ?> [/code]
  2. I'm not sure, how do I check??? On the last hosting site I right clicked on images and changed the chmod or something but when I right click on this i cant do anything
  3. I'm trying to upload images into my database, along with data on them. The values including the image name are being stored in the db but the image is not uploading. I have used the exact same code before but with a different hosting company. The message I am getting is: Warning: move_uploaded_file(/home/groover/public_html/images/pure.jpg): failed to open stream: Permission denied in /home/groover/public_html/admin_insert.php on line 54 Warning: move_uploaded_file(): Unable to move '/tmp/phpudG2GY' to '/home/groover/public_html/images/pure.jpg' in /home/groover/public_html/admin_insert.php on line 54 Any idea what would cause this error?? [code] <?php //check for required fields from the form if ((!$_POST[uname]) || (!$_POST[pword])) { header("Location: adminlogin.html"); exit; } //connect to server and select database $conn = mysql_connect("localhost", "groover", "dwde909") or die(mysql_error()); mysql_select_db("groover_walshy",$conn) or die(mysql_error()); //create and issue the query $sql = "select *from admin where uname = '$_POST[uname]' AND pword = '$_POST[pword]'"; $result = mysql_query($sql,$conn) or die(mysql_error()); //get the number of rows in the result set; should be 1 if a match if (mysql_num_rows($result) == 1) { //if authorized, get the values of fname lname $fname = mysql_result($result, 0, 'fname'); $lname = mysql_result($result, 0, 'lname'); //set authorization cookie setcookie("auth", "1", 0, "/", "grooverecord.net", 0); //create display string $display_block = "<P>$fname $lname is authorized!</p> <P>Authorized Users' Menu: <ul> //<li><a href=\"secretpage.php\">secret page</a> </ul>"; } else { //redirect back to login form if not authorized header("Location: adminlogin.html"); exit; } header("Location: adminwelcome2.php? login=true&id=$uname"); exit(); ?> <HTML> <HEAD> <TITLE>User Login</TITLE> </HEAD> <BODY> <? echo "$display_block"; ?> </BODY> </HTML> [/code]
  4. Wooo Hooo!! Its working! lol, thanks wildteen your a legend!! As you can see I know nothing about coding! lol. I have a delete page to do now, hopefully it will be pretty much the same but change the sql in it, think I'm gonna leave that till tomorrow though! Thanks for giving up your day, really appreciate it!  :)
  5. lol, almost there I hope! Just getting some error messages now, it said there was an inexpected ')' on this line $row = mysql_fetch_array($result1, MYSQL_ASSOC)) So I removed the 2nd ')' now I get the message Parse error: parse error, unexpected T_ECHO in /home/c/ciaracousins/public_html/admin_update2.php on line 99 line 99: [code]  echo'<tr>//line 99         <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td>         <td align="left">' . $row['prodId'] . '</td>       </tr> [/code]
  6. Still not working! I wasnt sure whether the submittedUpdate mattered in this line if($key != 'prodId' || $key != 'shopName' || $key != 'submittedUpdated') But I changed it to if($key != 'prodId' || $key != 'shopName' || $key != 'submittedUpdate') to try it but still didnt make any difference
  7. Now when I click on update it just brings me to a blank admin_update2.php page
  8. Its still going back to the original value  ???... Its got rid of the second button though
  9. Its still not working, when I did that and clicked on update it created and second update button and the it still changes it back to the original value. I seem to have 2 values for submit You can check it yourself what I mean http://snet.wit.ie/~ciaracousins/admin_update2.php?login=true&shopName=savage&prodId=2
  10. ok now it is showing the details in the table again, but when I click on the update button it just changes the value back to what it was before. For example I wanted to change the price of a product. In the table it was 49.99 but I changed it to 39.99. When I clicked on UPDATE, it just changed back to 49.99
  11. It threw me this error that time: Unable to perform query2 SELECT * FROM product WHERE prodId = '106' and shopName='savage' Query was empty
  12. Ok now its not bringing up the table with the details to be updated because its not getting the values from the URL. This is the problem I've been having for the past few days. I changed Get to Post in this line $prodId = isset($_POST['prodId']) ? $_POST['prodId'] : '0'; The way I am passing the details through is appending the prodId to the URL. [code] <td align="center"><a href="admin_update2.php?login=true&shopName='.$row['shopName'].'&prodId='.$row['prodId'].'"><img src="http://snet.wit.ie/~ciaracousins/clothes/' . $row['image'] . '"></a> [/code]
  13. ok its throwing no error messages now. Its still not updating. The URL just says http://snet.wit.ie/~ciaracousins/admin_update2.php
  14. ok so I changed the code to that [code] $prodId = 0;  // wasnt sure if this was to be left in but it doenst seem to make any difference when I take it out $prodId = isset($_GET['prodId']) ? $_GET['prodId'] : '0' $sql = "SELECT * FROM product WHERE prodId=$prodId";// line 77 [/code] now it says Parse error: parse error, unexpected T_VARIABLE in /home/c/ciaracousins/public_html/admin_update2.php on line 77
  15. Aaah I'm stupid! That has solved the deleting problem! Thanks Wildteen!! Now when I try to update something it says: Unknown column 'INVALID' in 'where clause'
×
×
  • 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.