Jump to content

shamwowy

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

shamwowy's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks guys/gals! I will try this out and close out this thread when I get home and it works .
  2. The code is doing what I want it to do with the slight exception of dropping every 6th database record. So it prints a row of 5 records, then record #6 disappears, then it prints another row of 7-11, drops #12, etc.
  3. Did you try: $referer = $_SERVER['HTTP_REFERER']; $checkpost = 'post.php'; if (strpos($referer,$checkpost)) { echo '<div id="posted">'; echo '<p align="center">Posted successfully below!<br/></p>'; echo '</div>'; } In theory, strpos() should look for any string you pass in, in this case just look for post.php in your referer string.
  4. Hi all, I'm trying to print a list of records out of my database in a table. Each row contains 5 cells and is then supposed to loop into the next row of 5 cells until there are no more rows. The table is building almost correctly, with the slight problem of every 6th record is not showing up. Here's the code: <tr> $query1 =" SELECT * FROM jitem JOIN jloc ON jloc.jloc_id IN(jitem.jitem_location) WHERE jitem.jitem_display = 1 ORDER BY jitem_listorder"; if( $r = mysql_query($query1) ) { $ii = 1; while( $row = mysql_fetch_assoc($r) ) { if ($ii <= 5) { print "<td width=20% valign=top align=center>"; print "<a href='slides/{$row['jitem_slide']}' title='{$row['jitem_title']}' border=0 onclick=\"window.open(this.href, '','height=545,width=500');return false;\">"; print "<img border=0 src='thumbs/{$row['jitem_thumb']}' alt='{$row['jitem_title']}'/><br/>"; print "<font size=2 color=white><strong>{$row['jitem_title']}</strong></a><br/>{$row['jitem_desc']}<br/>"; print "\${$row['jitem_price']}</font>"; print "<br/><font size=2><a href=cart.php?itemid=".$row['jitem_id']."&action=add>Add To Cart</a></font>"; print "</td>"; $ii ++; } else { print "</tr><tr><td colspan=5> </td></tr><tr>"; $ii = 1; } } } else { print "Database returned no records. query1 is ".$query1.""; } mysql_close(); Something is wrong with my counter but I'm not sure what. My output looks like this: Item1 Item2 Item3 Item4 Item5 Item7 Item8 Item9 Item10 Item11 Item13 Item14 Any thoughts on my counter? Is <= 5 my problem? Or am I resetting $ii in the wrong spot? I've tried a few variations but it just makes things really bad. Any help greatly appreciated.
  5. Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50 My issue with the string above is that it seems to be saying Safari version 5.1. Does anyone have an older install of Safari maybe that can show me a different safari string? Or is the number 534.50 above the actual versioning number that I should be concerned with?
  6. Hi all. I'm trying to redirect a user if and only if they are using Safari 5.0.5 or below (both Win and Mac). The code is thus: if ($_SERVER['HTTP_USER_AGENT'] <= 'Safari V. 5.0.5 and lower'); //what should the second half of this line look like? { header( 'location:http://mydomain.com/safari.php' ); } I'm not really sure if there's a nifty RegEx way to do this, and also I don't really know how to do an <= comparison given the http_user_agent returns a giant string of madness. A bunch of my users are stuck with Safari 5.0.5 and can't update to latest, and those versions don't support some of my CSS3 calls. Any help would be most appreciated.
  7. Right you are kind sir. With print_r($cart) I get the following: Array ( [6] => 1 [12] => 1 ) That being productID 6 x1 and productID 12 x1. Trying to get my function to tell me that there are 2 items total. It looks like the comma delimeter is not being inserted into this, or does it just not display in the output of print_r ? Thanks again.
  8. I should note that print_r($items) returns Array ( [0] => ) even if I have 5 things in the cart. This seems odd to me considering that when I use the cart to hit my database it's getting each ID from there, so it's in there somewhere. I will keep trying.
  9. Thanks a bunch! This doesn't work (still returns just 1 item count), but it validates that explode is the right function. Also thanks for pointing me at print_r which I didn't know about. (New to PHP coming from CF)
  10. Hi all, I'm building a simple shopping cart and my function is not returning the correct item count. It will correctly tell me if there are no items in the cart, however, if there is 1 or more items, the count always returns as 1, no matter how many items are actually in there. Here's the add item to cart code, which works fine: $product_id = $_GET['itemid']; $action = $_GET['action']; switch($action) { case "add": $_SESSION['cart'][$product_id]++; break; Then I'm using the following function in my header include file (which is included on every page) function writeShoppingCart() { $cart = $_SESSION['cart']; if (!$cart) { return '0 Items in Cart'; } else { // Parse the cart session variable $items = explode(',','$cart[product_id]'); $s = (count($items) > 1) ? 's':''; return '<a href="cart.php">View Cart</a> <font color=white size=2>['.count($items).' item'.$s.']</font>'; } } This function always returns 1 item even if it's 4 or 5 items in the cart. My session[cart] contains all the items, as I can see when I go to display them all. I'm thinking I'm either not using explode() correctly here (it's treating everything inside the cart var as a single string even though there are commas in there) or I'm not supposed to be using explode at all based on the variable type. If anyone can help with this I'd really appreciate it. Many thanks in advance.
  11. Many thanks! I had thought there would be something I could reference directly in the result object itself but this works too.
  12. Hi all, dumb question I'm sure but not finding the answer so far... I'm trying to reference the row number in a sql query resultset loop. if( $r = mysql_query($query1) ) // LOTS AND LOTS OF ROWS RETURNED { while( $row = mysql_fetch_assoc($r) ) // LOOP { print "Phone - {$row['jloc_phone']}<br/>"; print "This is record number ".$what_var_here."<br/>"; //HOW TO REFENCE MY ROW NUMBER HERE? } } } I've tried variations with $row and $r which return either "Array" or "resource". I'm assuming it's something like $row[count] or some such thing that I'm just not finding. Many thanks in advance for any assistance on this.
  13. Hi all. Just wondering if anyone has a favorite, simple, safe password reset method that I haven't thought of. I'm currently leaning toward having the user click a "reset password" link, enter an email address, then creating and emailing a temp password to the email address (from a matched database record), then having user change password based on login with the temp password sent via email. That seems a few too many steps for my userbase (mostly old ladies). Any thoughts on something easier (for the old ladies) that is still simple and safe? Thanks for any thoughts y'all may have.
×
×
  • 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.