Jump to content

danielforsyth

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

danielforsyth's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I downloaded an open source shopping cart and I am having problems with it because of the WEB_ROOT function. i.e. Links that should go to [a href=\"http://root.danielforsyth.com/shop/admin/category/\" target=\"_blank\"]http://root.danielforsyth.com/shop/admin/category/[/a] are going to [a href=\"http://root.danielforsyth.com/homepages/44/d88778109/htdocs/shop/admin/category/\" target=\"_blank\"]http://root.danielforsyth.com/homepages/44...admin/category/[/a] So do I need to change a setting with my host? or do I need to change the code in the config file... here it is: // setting up the web root and server root for // this shopping cart application $thisFile = str_replace('\\', '/', __FILE__); $docRoot = $_SERVER['DOCUMENT_ROOT']; $webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile); $srvRoot = str_replace('library/config.php', '', $thisFile); define('WEB_ROOT', $webRoot); define('SRV_ROOT', $srvRoot); please help! thanks.
  2. I am new to php and to paypal, but I don't think this question is very hard... I have an "inventory_count" column in a mysql table. I want the inventory count to subtract one every time I sell that item through paypal. I have the IPN script from the paypal site and I added a few lines of code to try to accomplish this task... but the inventory_count remains unchanged. I have my sandbox account set to reference this script in the IPN section. Can somebody tell me what I am doing wrong? I only added the part between "process payment" and "else if". And for some reason I get an error when I try to post all the code here... but here is what I added: $query = "SELECT inventory_count FROM tm_inventory WHERE id = $item_number"; $result = mysql_query($query); $row = mysql_fetch_array($result, MYSQL_ASSOC); $inventory_count = $row['inventory_count']; $new_inventory_count = $inventory_count - 1; $query2 = "UPDATE tm_inventory SET inventory_count = '$new_inventory_count' WHERE id = $item_number"; mysql_query($query2);
  3. I am new to php and to paypal, but I don't think this question is very hard... I have an "inventory_count" column in a mysql table. I want the inventory count to subtract one every time I sell that item through paypal. I have the IPN script from the paypal site and I added a few lines of code to try to accomplish this task... but the inventory_count remains unchanged. I have my sandbox account set to reference this script in the IPN section. Can somebody tell me what I am doing wrong? I only added the part between "process payment" and "else if". And for some reason I get an error when I try to post all the code here... but here is what I added: $query = "SELECT inventory_count FROM tm_inventory WHERE id = $item_number"; $result = mysql_query($query); $row = mysql_fetch_array($result, MYSQL_ASSOC); $inventory_count = $row['inventory_count']; $new_inventory_count = $inventory_count - 1; $query2 = "UPDATE tm_inventory SET inventory_count = '$new_inventory_count' WHERE id = $item_number"; mysql_query($query2);
  4. got it, so I just need a space after the DESC?
  5. I am trying to display the contents of a mysql table in descending order by "id". The script works fine until I add in the ORDER BY to the query. You can see below that I have the ORDER BY coded only if $category = hand, so I get an error now if category = hand, but not if category = baby or if cat = makeup. [code] // how many rows to show per page $rowsPerPage = 6; // by default we show first page $pageNum = 1; $category = $_GET['category']; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) {     $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; if ($category == "hand"){ $query  = "SELECT price, title, id FROM tm_inventory WHERE category='hand' ORDER BY id DESC"; } elseif ($category == "baby"){ $query  = "SELECT price, title, id FROM tm_inventory WHERE category='baby'"; } elseif ($category == "makeup"){ $query  = "SELECT price, title, id FROM tm_inventory WHERE category='makeup'"; }            $pagingQuery = "LIMIT $offset, $rowsPerPage"; $result = mysql_query($query . $pagingQuery) or die('Error 1, query failed'); // print the inventory info in table echo '<table border="0" cellpadding="2" cellspacing="0">'; while($row = mysql_fetch_array($result)) {    $row2 = mysql_fetch_array($result) or $row2['id'] = "1" and $row2['title'] = "&nbsp;";    $row3 = mysql_fetch_array($result) or $row3['id'] = "1" and $row3['title'] = "&nbsp;";    printf("<tr><td align='center'> <img src=\"image3.php?id=%s\" width='150'><br> %s <br> %s </td> \n", $row["id"], $row["title"], $row["price"]);    printf("<td align='center'> <img src=\"image3.php?id=%s\" width='150'><br> %s <br> %s </td> \n", $row2["id"], $row2["title"], $row2["price"]);    printf("<td align='center'> <img src=\"image3.php?id=%s\" width='150'><br> %s <br> %s </td></tr>", $row3["id"], $row3["title"], $row3["price"]); } echo '</table>'; echo '<br>'; // how many rows we have in database $result  = mysql_query($query) or die('Error 2, query failed'); $numrows = mysql_num_rows($result); // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); $self = $_SERVER['PHP_SELF']; // creating 'previous' and 'next' link // plus 'first page' and 'last page' link // print 'previous' link only if we're not // on page one if ($pageNum > 1) {     $page = $pageNum - 1;     $prev = " <a href=\"$self?category=$category&page=$page\">[Prev]</a> ";     $first = " <a href=\"$self?category=$category&page=1\">[First Page]</a> "; } else {     $prev  = ' [Prev] ';       // we're on page one, don't enable 'previous' link     $first = ' [First Page] '; // nor 'first page' link } // print 'next' link only if we're not // on the last page if ($pageNum < $maxPage) {     $page = $pageNum + 1;     $next = " <a href=\"$self?category=$category&page=$page\">[Next]</a> ";     $last = " <a href=\"$self?category=$category&page=$maxPage\">[Last Page]</a> "; } else {     $next = ' [Next] ';      // we're on the last page, don't enable 'next' link     $last = ' [Last Page] '; // nor 'last page' link } // print the page navigation link //echo $first . $prev . " Page <strong>$pageNum</strong> of <strong>$maxPage</strong> " . $next . $last; echo $prev . " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Page <strong>$pageNum</strong> of <strong>$maxPage</strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " . $next; [/code] Here are some links so you can see what happens: [a href=\"http://root.danielforsyth.com/mysql/image_upload/view5.php?category=hand\" target=\"_blank\"]http://root.danielforsyth.com/mysql/image_...p?category=hand[/a] [a href=\"http://root.danielforsyth.com/mysql/image_upload/view5.php?category=baby\" target=\"_blank\"]http://root.danielforsyth.com/mysql/image_...p?category=baby[/a] Please tell me how to fix this - thx
  6. Thanks - Here is the entire script: // how many rows to show per page $rowsPerPage = 9; // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; $query = "SELECT price FROM inventory "; $pagingQuery = "LIMIT $offset, $rowsPerPage"; $result = mysql_query($query . $pagingQuery) or die('Error, query failed'); // print the inventory info in table echo '<table border="1"><tr>'; while(list($price) = mysql_fetch_array($result)) { for ( $i = 1; $i < 4; $i++ ) { echo "<td>$price</td>"; } echo '</tr><tr>'; } echo '</tr></table>'; echo '<br>'; // how many rows we have in database $result = mysql_query($query) or die('Error, query failed'); $numrows = mysql_num_rows($result); // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); $self = $_SERVER['PHP_SELF']; // creating 'previous' and 'next' link // plus 'first page' and 'last page' link // print 'previous' link only if we're not // on page one if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page\">[Prev]</a> "; $first = " <a href=\"$self?page=1\">[First Page]</a> "; } else { $prev = ' [Prev] '; // we're on page one, don't enable 'previous' link $first = ' [First Page] '; // nor 'first page' link } // print 'next' link only if we're not // on the last page if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page\">[Next]</a> "; $last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> "; } else { $next = ' [Next] '; // we're on the last page, don't enable 'next' link $last = ' [Last Page] '; // nor 'last page' link } // print the page navigation link echo $first . $prev . " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " . $next . $last; mysql_close($conn);
  7. [!--quoteo(post=341236:date=Jan 30 2006, 02:28 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 30 2006, 02:28 PM) [snapback]341236[/snapback][/div][div class=\'quotemain\'][!--quotec--] Not true -- open the TR if you're on an even row, and close it if you're on an add row. What's the problem? Like I said above, if you do this using your own for() loop, you can do it two at a time. [/quote] Fenway - I am having the same problem. Could you tell me what is wrong with this code? I want to have a 3x3 table with each cell showing a different value. echo '<table border="1"><tr>'; while(list($price) = mysql_fetch_array($result)) { for ( $i = 1; $i < 4; $i++ ) { echo "<td>$price</td>"; } echo '</tr><tr>'; } echo '</tr></table>'; The results of the code above can be see here: [a href=\"http://root.danielforsyth.com/mysql/image_upload/view2.php?page=1\" target=\"_blank\"]http://root.danielforsyth.com/mysql/image_...iew2.php?page=1[/a] I also tried the code below, but it had a different problem. It would put three columns in the first row, but four columns in the second row, as you can see at this link: [a href=\"http://root.danielforsyth.com/mysql/image_upload/view3.php?page=1\" target=\"_blank\"]http://root.danielforsyth.com/mysql/image_...iew3.php?page=1[/a] echo '<table border="1"><tr>'; $thenum = 1; while(list($price) = mysql_fetch_array($result)) { if($thenum > 3){ $thenum = 1; echo '</tr><tr>'; } else{ $thenum++; } echo "<td>$price</td>"; } echo '</tr></table>'; As I'm sure you can tell, I'm new at php. Any help would be appreciated. Thanks
×
×
  • 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.