Jump to content

widget

Members
  • Posts

    148
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

widget's Achievements

Member

Member (2/5)

0

Reputation

  1. Sorry Zane There is a table of item a user has in their shop. They can click a button next to the pricing field in their shop that will set the price for them by searching the database of all users shops for that item, retrieving the cheapest price and setting their price $1 less. The trouble is, when it comes across an item that noone else has in stock it doesnt know what to do and simply just uses the previous items price.
  2. Heres the setup Virtual pet site, users shop. They can click on an icon that will price their item 1 point less than the lowest existing. Trouble is, if no-one else has that item in stock, the icon prices the item the same price as the previous item listed. Example Chocolate Bar $1 Red Hat $1 <--- theres none of these in any other shop therefor it needs to return $0 Here is my code. $findResults = mysql_query("SELECT * FROM usershops_items2 WHERE price > '0' AND item_id = '$find_item2[id]' ORDER BY price ASC LIMIT 1"); while ($getResults = mysql_fetch_array($findResults)) { $cheap = $getResults[price]; $cheap2 = $cheap -1; } $cheap = "<span onclick=\"MM_setTextOfTextfield('item_price[$id]','','$cheap2')\"><img src=images/items/item_747.gif width=24 height=24></span>"; I have tried adding in if statements in different places but nothing works.
  3. Thank you for your advice although I managed to get it working with the below code. Theres probably a much neater way to do it though. $sql_query = "SELECT id,item_name FROM items2 WHERE item_type = 'intel_inc'"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { while($row = mysql_fetch_row($result)) { $books_id = $row[0]; $find_pet = fetch("SELECT item_id FROM read2 WHERE pet_id = '$id' AND item_id = '$books_id'"); $pets_books_id = $find_pet[item_id]; if ($pets_books_id == $books_id) { ?> <style> .book2 img{ opacity:1.0; filter:alpha(opacity=100); /* For IE8 and earlier */ </style> <? echo ("<div class='book book2'><a href=/books/$books_id.php><img src='$base_url/images/items/item_$books_id.gif' width='64px' height='64px'><br>$row[1]</a> </div> "); } else { ?> <style> .book3 img{ opacity:0.2; filter:alpha(opacity=20); /* For IE8 and earlier */ </style> <? echo ("<div class='book book3'><img src='$base_url/images/items/item_$books_id.gif' width='64px' height='64px'><br>$row[1] </div> "); } } } //if no fields exist else { echo "no values in the database"; } ?>
  4. Using mysql and php 5 Table 1 is a list of books. Table 2 is a list of userids and the books read. USER_ID | ITEM_ID ________________ 1 | 345 1 | 456 2 | 345 2 | 457 2 | 347 My page displays images (opaque) of all books available from Table 1 In the while statement that displays the books, I would like to check Table 2 for a match and if the user has read it, the image is not opaque and also contains a link. I have no clue on the best way to do this. Below is my code so far. $sql_query = "SELECT id,item_name FROM items2 WHERE item_type = 'intel_inc'"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { while($row = mysql_fetch_row($result)) { $get_books_read = mysql_query("SELECT item_id FROM read2 WHERE user_id = '$id'"); if( IF THERE IS A MATCH ) { echo ("<div class='book_yes'><img src='$base_url/images/items/item_$row[0].gif' width='64px' height='64px'><br>$row[1]</div> "); } else { echo ("<div class='book_no'><a href='#'><img src='$base_url/images/items/item_$row[0].gif' width='64px' height='64px'><br>$row[1]</a></div> "); } } } //if no fields exist else { echo "no values in the database"; } Thanks in advance for any help offered.
  5. Hi Guys My site has a shout box, now and again people post inappropriate content and if a moderator is not online to mute them it doesnt look good for other users. I have written a snippet of code to report an offender. My goal is that if 3 different people report an offender the site auto mutes them. (manual mute function already exists for moderators) I setup a table that records the reporters name the offenders name the post id the message content and the time stamp. I have never been good at counting num rows etc and need some help in what direction to go in. My current code that inserts the reported content. mysql_query("INSERT INTO `chicka_pets`.`records_sbreports` (`id`, `offender`, `reporter`, `post_id`, `post_content`, `timestamp`) VALUES ('', '$offender', '$username', '$id', '$sbmessage', '$timestamp')"); I am guessing that somewhere after that I need some sort of count numrows on the post id where reporter is NOT the same and then an if numrows >2 set offender to mute my problem is how to do the num rows bit where the reporters are unique? Any help is much appreciated
  6. Thank you so much num rows worked a treat Just in case anyone else has a similar problem here tis the code <FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD=get> <input type="text" name="band" value="<?php echo $_GET['band']; ?>" /> <input type="text" name="bust" value="<?php echo $_GET['bust']; ?>" /> <INPUT TYPE=submit VALUE="Calculate"> </FORM> <?php if(isset( $_GET['band']) && isset($_GET['bust']) ){ $band = $_GET['band']; $bust = $_GET['bust']; $query = sprintf("SELECT size FROM bra_calculator WHERE band='%s' AND bust='%s'", mysql_real_escape_string($band), mysql_real_escape_string($bust)); $result = mysql_query($query); $num_rows = mysql_num_rows($result); if (!$num_rows) { echo "N/A"; } else { while ($row = mysql_fetch_assoc($result)) { echo "$row[size]"; } } mysql_free_result($result); }
  7. Sadly that just displays N/A before submitting the form but thank you for your help
  8. I have written a bra calculator, when the user enters their measurements their bra size is displayed however as the code I have used to do this came from a help tutorial I do not understand how it was constructed as I am quite a newb. The form works perfectly when returning data however if there is no size for a particular measurement it just displays nothing. I would like it to display N/A I have tried adding various if elses but without success. Any help is much appreciated <FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD=get> <input type="text" name="band" value="<?php echo $_GET['band']; ?>" /> <input type="text" name="bust" value="<?php echo $_GET['bust']; ?>" /> <INPUT TYPE=submit VALUE="Calculate"> </FORM> <?php $band = $_GET['band']; $bust = $_GET['bust']; $query = sprintf("SELECT size FROM bra_calculator WHERE band='%s' AND bust='%s'", mysql_real_escape_string($band), mysql_real_escape_string($bust)); $result = mysql_query($query); if (!$result) { echo "no"; } else { while ($row = mysql_fetch_assoc($result)) { echo $row['size']; } } mysql_free_result($result); ?>
  9. eh I dont understand it - think I will move on to another alternative
  10. hmm I have to go out for a bit but will try this as soon as I am back - I have never gotten into sessions before so should be interesting. Thanks
  11. what's your opinion on using javascript such as... <script type="text/javascript"> function myfunc () { var frm = document.getElementById("foo"); frm.submit(); } window.onload = myfunc; </script>
  12. this works but I was looking for a way to auto redirect them back to PageA and not have them click a button but after lots of reading I think this is impossible.
  13. with your example I can replicate it simply by adding die("You have won a fantastic prize!!!!"); but I don't know if this is good coding practice as I am only following what I am being shown.
  14. thank you - that code works but I need it to redirect the user back to page A and display the message, for example at the top of the page.
×
×
  • 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.