Jump to content

emma57573

Members
  • Posts

    106
  • Joined

  • Last visited

    Never

Everything posted by emma57573

  1. Thank you for that example, that is exactly the type of thing that I'm thinking. A tag cloud at the top of each category page in order of the most popular tag first. Its just good to know what I'm doing before I go and code it as its quite a big change to the site and I want to get it 'right'. I suppose it would be very similar to the search function I have that searches through titles/descriptions within the category. If anyone has anymore examples I would find that extremely useful Thanks
  2. Im in the process of adding tags to my site to manage the shopping areas This is the site to give you an idea misi.co.uk At the moment the items are placed into categories but what Im going to do is get the user to choose a category and then enter some tags to go with it. So you are able to browse/search through tags within each category. Im fine with getting users to insert the tag code into MYSQL Im thinking more on the lines of how to manage the search/browse function and what is the best way around it. Does anyone have links to some good tag tutorials? Or links to sites that use tags to manage their categories that I could look at? Tags are becoming increasingly popular but I cant seem to find any infomation on them from a coding point of view. Im not 100% sure how to best go about it.
  3. I dont think so as the code is still going into your page its just being called for instead.
  4. Still nothing Ive been playing with 'IS NOT EMPTY STRING' but with no luck
  5. Ive forgotton how to do this and cant find the syntax Im searching in a mysql table and I want to say if the field is blank! If you get hat I mean so: $mytable=mysql_fetch_array(mysql_query("select * from mysqltable where !field=""")); but you cant do '!' in the middle of a query for !field="" so what can you do to ask if the field is blank? Thanks
  6. Thank you I will check that out! that looks simpler
  7. Im using a script that lets the user upload a file up to 400k. But what I really want to do is resize the image before I save it. This is how I get the image: if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { $realname = $_FILES['userfile']['name']; ///////--------chking extension if(!preg_match("/(\.jpg|\.png|\.gif|\.bmp|\.jpeg)$/i",$realname)) die(); ///////--------end chking extension if ($_FILES['userfile']['size']>(400000)) $mess="Uploaded files must be less than ".(400000/1000)."k. Please try again"; elseif($_FILES['userfile']['size']<=0) $mess="File could not be uploaded. Please try again"; else { $insert="no"; switch($_FILES['userfile']['error']) { case 0: $mess = "Image has been uploaded successfully"; $insert="yes"; break; case 1: case 2: $mess = "Error : File size more than maximum size allowed by server";break; case 3: $mess = "Error : File partially uploaded"; break; case 4: $mess = "Error : No File Uploaded"; break; } Obviously theres more to it but thas the important part now instead of finding out what size it is and throuwing up an error, I want to find out what size it is and if its over 250k I want to resize it down to 250k. is there any simple bit of code that does it Ive looked at some scripts for this but cant find one that would let me do it simply without changing my entire code?
  8. Thanks Ive figured it out now
  9. Im having problems formatting a date from mysql to php In the database its 2008-10-19 08:48:09 and I want it to read 19 Oct 2008 8:48 (or something simular) in php Instead at the moment its reading Thu Jan 01st,1970 01:33 am No matter what date is in the database!! I am using a classified script and I have acomlished this on other php pages by using the following echo freetpl_date($rst["get_date"],0); But I can find the function freetpl_date anywhere to see whats happening! If there a simple way to format this date?
  10. Thanks It still wasnt calculating right so in the end i took out the 'OR' part and added the two together instead, it seems to be giving me the right percentage at last $feed="SELECT count(*) from feedback WHERE user_id=$user_id and score=2"; $sum=mysql_query($feed); $feedpercent=mysql_fetch_array($sum); $num_rows = mysql_num_rows($sum); $feedback="SELECT count(*) from feedback WHERE user_id=$user_id and score=1"; $possum=mysql_query($feedback); $feedscore=mysql_fetch_array($possum); $num_pos = mysql_num_rows($possum); $addsum+= $num_rows + $num_pos; $score+= (($num_pos / $addsum) * 100);
  11. Whay is this giving me the wrong calculation? I am trying to work out the percentage of positive feedback this should be giving me 50% but is outputting at 40% The structure of feedback is like this: user_id,score,Comment,from_id,id,get_date_proid The important fields here are user_id and score Score works like this: 1= positive 2= negative 3= neutral $feed="select * from feedback WHERE user_id=$userid and score=1 OR score=2"; //echo $freetplquery; $sum=mysql_query($feed); $feedpercent=mysql_fetch_array($sum); $num_rows = mysql_num_rows($sum); $feedback="select * from feedback WHERE user_id=$userid and score=1"; //echo $freetplquery; $possum=mysql_query($feedback); $feedscore=mysql_fetch_array($possum); $num_pos = mysql_num_rows($possum); $score+= (($num_pos / $num_rows) * 100); Im guessing its my sum thats incorrect but am unsure
  12. FIXED ;D Just a silly capital letter in the database title
  13. forget that I know $_POST is working because I just tested it so thats something! it must be something to do with the way im trying to insert the data
  14. Ok Ive written a bit of code that I thought would work! I dicided to use the same loop as the previous page in the same order and then do a mysql insert in the loop if ($rst) { $cnt=0; while($rst) { $pid=$rst["pid"]; $feed_score=$_POST["feedbox$pid"]; $feed_comm=$_POST["comments$pid"]; $insert= "INSERT INTO freetplclassified_feedback (user_id,score,comment,from_id,id,getdae,pro_id)VALUES('$userid','$feed_score','$feed_comm','$userid','','','$pid')"; mysql_query($insert); if(mysql_affected_rows()>0){ ?> Worked!! <? }else{ ?> Went wrong <? } $rst=mysql_fetch_array($sql); $cnt++; }// end while The loop is working but the insert to mysql isnt. Im not sure if im calling the $_POST right as it also has a variable in the name. I think this could be where im going wrong????
  15. The form works fine basically all I need to know is how to create an array from the form data onto the next submit page. So I can then put it into a loop and submit what I need to into mysql. Does that make sence? I just want to know if its possible to get the data into an array and how I would go about it? Im at a bit of a loose end with this.
  16. Im not quite sure how to handle the output of this loop $freetplquery="select * from mytable_sold where seller=".$userid." or buyer=".$userid.""; $sql=mysql_query($freetplquery); $rst=mysql_fetch_array($sql); ?> MY LEAVE FEEDBACK FORMS <table> <tr> <td> <? if ($rst) { ?> <FORM name="leavefeed" method="POST" action="updatefeedback.php" onsubmit="return Validate(this);"> <table> <? $cnt=0; while($rst){ $aid=mysql_fetch_array(mysql_query("select * FROM MYTABLE_products WHERE user=".$rst["pid"])); ?> <table> <tr> <td><? echo $aid["product_name"];?></td> </tr> <tr> <td><input name="feedbox<? echo $rst["pid"]; ?>" type="radio" value="" /><h2>Positive</h2></td> <td><input name="feedbox<? echo $rst["pid"]; ?>" type="radio" value="" /><h2>Neutral</h2></td> <td><input name="feedbox<? echo $rst["pid"]; ?>" type="radio" value="" /><h2>Negative</h2></td> <td><input name="feedbox<? echo $rst["pid"]; ?>" type="radio" value="" /><h2>Not Now</h2><br /></td> </tr> <tr> <td><b>Comments:</b><br /> <textarea name="comments<? echo $rst["pid"]; ?>"></textarea> </td> </tr> </table><br /> <? $rst=mysql_fetch_array($sql); $cnt++; }// end while ?> <input name="submit" type="submit" value="Submit your Feedback" /> </td> </tr> </table> </form> Ive tried to simplify this as much as possible so the code is watered down. When it gets to this page 'updatefeedback.php' The data is added to a mysql table. Thats where im stuck. How do I enter while loop details into a database? Do I need to create a simular loop in 'updatefeedback.php' that writes to mysql after every loop? and if so how do i pick up the form data as a loop. Or is there a simply way of doing this and im making life hard on myself (as usual!)
  17. I have some code that im using on my site thats works great, I want to use the same code on my PHPBB Forum but in order to run smoothly I need to covert it to javascript. However its not working so somethings wrong with my syntax. If anyone could help that would be great. This is the working code <?PHP //script for the <BODY> area of your source code, transferring necessary user data //place this script on every page if the user is logged in !!! $tk_name = "$V3CHAT_NAME"; //<-- please set the username here $tk_user_id = "$V3CHAT_USER"; //<-- please set the user ID here $tk_gender = ""; //<-- optional (the gender of the user can be female or 'male') $tk_age = ""; //<-- optional (the age of the user e.g. '23') $tk_single = ""; //<-- optional (is the user single? 'Yes', 'no', '0' = no information) $tk_profile_url = ""; //<-- optional (url to the users profile) $tk_pic = ""; //<-- optional (url of the users picture) $tk_city = ""; //<-- optional (city where the user is located, e.g. 'Berlin') $tk_zip = ""; //<-- optional (users zip code, e.g. '92553') $tk_country = ""; //<-- optional (country where the user is located, e.g. 'Germany') //DO NOT EDIT THE FOLLOWING CODE! $tk_user_data="name:".$tk_name. ";gender:".$tk_gender. ";age:".$tk_age. ";single:".$tk_single. ";url:".$tk_profile_url. ";pic:".$tk_pic. ";city:".$tk_city. ";tk_zip:".$tk_zip. ";country:".$tk_country; //implements the js needed by the chatWatcher and to start a chat $tk_hash = md5($tk_user_id.$tk_user_data."wcwUrTFHLbpMeV9vcnSp"); $tk_js = "<script type='text/javascript' src='http://www.toksta.com/js/w/?tk_hash=" . $tk_hash . "&app_id=87879&app_user_id=".$tk_user_id."&tk_user_data=".rawurlencode($tk_user_data)."'></script>" . "<script type='text/javascript' src='http://www.toksta.com/js/tokstaIm/?tk_hash=" . $tk_hash . "&app_id=87879&app_user_id=".$tk_user_id."&tk_user_data=".rawurlencode($tk_user_data)."'></script>"; echo $tk_js; ?> This is how ive converted it for phpbb. It just comes up with a java error popup <script type='text/javascript' src='http://www.toksta.com/js/w/?tk_hash=md5("{USER_ID}". name:"{USER_NAME}"; gender:""; age:""; single:""; url:""; pic:""; city:""; tk_zip:""; country:""; ."wcwUrTFHLbpMeV9vcnSp")&app_id=87879&app_user_id="{USER_ID}"&tk_user_data=".rawurlencode( name:"{USER_NAME}"; gender:""; age:""; single:""; url:""; pic:""; city:""; tk_zip:""; country:""; )."'> </script> <script type='text/javascript' src='http://www.toksta.com/js/w/?tk_hash=md5("{USER_ID}". name:"{USER_NAME}"; gender:""; age:""; single:""; url:""; pic:""; city:""; tk_zip:""; country:""; ."wcwUrTFHLbpMeV9vcnSp")&app_id=87879&app_user_id="{USER_ID}"&tk_user_data=".rawurlencode( name:"{USER_NAME}"; gender:""; age:""; single:""; url:""; pic:""; city:""; tk_zip:""; country:""; )."'> </script>
  18. Thats helpful and it works but the trouble is the array is in a while loop that adds keys to the array on every loop. If I add it in the loop it reads the last key on every loop and if I add it on the outside of the loop it will only read it for the last key. For example this is the page: The columns across are 'price' , 'qty' , 'shipping cost' and then 'sub total' What Im trying to input is the FINAL Total from each seller and then a payment in each sellers box. So if you see the small 16.00 in the left hand corner thats the code ive just added outside the while loop which is working but ONLY for the last seller in the loop. If I add it inside the loop then what happens is it adds the total after every product which of course is not what I want to do. Im thinking that this is a no go and I need to re think the way Ive written this whole page as its starting to get messy to be honest. Maybe I need to write the whole array before putting it in a while loop some how? This is the code that controls the loop: <?php $config=mysql_fetch_array(mysql_query("select * from mytable_config")); $freetplq_cur="select * from mytable_currency where user_id=".$config['cur_id']; $freetplrow_cur=mysql_fetch_array(mysql_query($freetplq_cur)); $freetpl_fee_currency=$freetplrow_cur['cur_name']; $query="select *,UNIX_TIMESTAMP(get_date) from mytable_sold where buyer_user_id=".$userid." and to_pay=1 order by seller_user_id DESC"; //echo $freetplquery; $sql=mysql_query($query); $rst=mysql_fetch_array($sql); $subshipping = preg_replace("/[^0-9\.]/", "", str_replace(',','.',$subshipping)); $cents = '.00'; $subshipping = preg_replace("/[^0-9]/", "", $subshipping); $subshipping=0.00; $total = preg_replace("/[^0-9\.]/", "", str_replace(',','.',$total)); $sents = '.00'; $total = preg_replace("/[^0-9]/", "", $total); ?> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable"> <tr> <td><h1>Payment Form </h1> </td> </tr> </table> <br> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" > <tr> <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top"> <div align="center"> <table width="100%" border="0" cellpadding="1" cellspacing="0"> <tr> <td align="center" valign="middle"> <? if ($rst) { ?> <table width="100%" border="0" cellspacing="2" cellpadding="5" class="onepxtable"> <tr><td> <table cellpadding="0" cellspacing="0" border="0"> <tr><td> <? $cnt=0; $countseller=array(); while($rst) { $seller_id= $rst["seller_user_id"]; $total=0.00; $countseller[]= $seller_id; $countarray = array_count_values($countseller); $aid=mysql_fetch_array(mysql_query("select * FROM freetplclassified_products WHERE user_id=".$rst["pid"])); $freetplq_img=mysql_fetch_array(mysql_query("select * from freetplclassified_images where pid=".$rst["pid"])); if ($countarray[$seller_id] == 1 ){ ?> </tr> </table> <table class="onepxtable" width="100%" cellpadding="5"> <tr> </td> <? } ?> <? $mid=mysql_fetch_array(mysql_query("select * FROM freetplclassified_members WHERE user_id=".$rst["seller_user_id"])); if ($countarray[$seller_id] >1 ){ ?> <? }else{ ?> <td width="12%" align="left" class="<? if($cnt%2<>0){echo "innertablestyle"; }else{echo "alternatecolor";}?>"> <font class="smalltext"> <a href="view_profile.php?user_id=<? echo $rst["seller_user_id"];?>" onclick="window.open(this.href); return false;"><? echo $mid["username"];?></a></font> </td> <? } ?> </tr> <tr> <td width="9%" align="left" class="<? if($cnt%2<>0){echo "innertablestyle"; }else{echo "alternatecolor";}?>"> <a href="product_desc.php?user_id=<? echo $rst["pid"];?>" onclick="window.open(this.href); return false;"> <img src="uploadedimages/<?php echo $freetplq_img["url"]; ?>" border="0" width="70" height="70"></a></td> <td width="28%" align="left" class="<? if($cnt%2<>0){echo "innertablestyle"; }else{echo "alternatecolor";}?>"><font class="smalltext"> <a href="product_desc.php?user_id=<? echo $aid["user_id"];?>" onclick="window.open(this.href); return false;"><? echo $aid["product_name"];?></a> </font></td> <td width="10%" align="left" class="<? if($cnt%2<>0){echo "innertablestyle"; }else{echo "alternatecolor";}?>"><font class="smalltext"> <? if($rst["buy_price"]>0) { echo $freetpl_fee_currency.' '; printf("%0.2f",$rst["buy_price"]); } else { echo "<font class='red'>($freetpl_fee_currency "; printf("%0.2f",$rst["buy_price"]*(-1)); echo ")</font>"; }?> </font></td> <td width="12%" align="left" class="<? if($cnt%2<>0){echo "innertablestyle"; }else{echo "alternatecolor";}?>"><font class="smalltext"> <? echo $rst["quantity"];?> </font></td> <td width="17%" align="left" class="<? if($cnt%2<>0){echo "innertablestyle"; }else{echo "alternatecolor";}?>"><font class="smalltext"> <? $uid=mysql_fetch_array(mysql_query("select * FROM freetplclassified_altaddress WHERE uid=".$userid)); $shipping_price=$rst["shipping_price"]; $combine_shipping_price=$rst["combine_shipping_price"]; $worldwide_shipping_price=$rst["worldwide_shipping_price"]; $worldwide_combine_shipping_price=$rst["worldwide_combine_shipping_price"]; $qty=$rst["quantity"]; $buyprice=$rst["buy_price"]; if (($rst["quantity"]==1)&&($uid["country"]==1)){ echo $shipping_price; }else if (($rst["quantity"]==1)&&(!$uid["country"]==1)){ echo $worldwide_shipping_price; }else if (($rst["quantity"]>1)&&($uid["country"]==1)){ $subshipping += ($combine_shipping_price * $qty); echo number_format($subshipping.$cents,2,'.',''); }else if (($rst["quantity"]>1)&&(!$uid["country"]==1)){ $subshipping += ($worldwide_combine_shipping_price * $qty); echo number_format($subshipping.$cents,2,'.',''); } ?> </font> </td> <td width="17%" align="left" class="<? if($cnt%2<>0){echo "innertablestyle"; }else{echo "alternatecolor";}?>"><font class="smalltext"> <? $total= $rst["total"]; echo number_format($total.$sents,2,'.',''); ?> </font></td></tr> <tr> <td width="17%" align="left" class="<? if($cnt%2<>0){echo "innertablestyle"; }else{echo "alternatecolor";}?>"><font class="smalltext"> <? //$result="SELECT sum(total) as total FROM freetplclassified_sold WHERE seller_user_id=".$seller_id; //$php = mysql_query($result); //if ($php) { // $row = mysql_fetch_array($php); // echo $row['total']; //} ?> </font></td> <? $rst=mysql_fetch_array($sql); $cnt++; }// end while ?> </td></tr> </table> <? $result="SELECT sum(total) as total FROM freetplclassified_sold WHERE seller_user_id=".$seller_id; $php = mysql_query($result); if ($php) { $row = mysql_fetch_array($php); foreach(array_keys($countarray) as $seller_id){ if($seller_id == array_pop(array_keys($countarray))){ echo $row['total']; } } } ?> <? }// end transaction found else { //////////////////////////////////////////////////////------------------ ?> <table width="100%" border="0" cellspacing="2" cellpadding="0" class="onepxtable"> <tr align="center" class="titlestyle"> <td height="25" align="left"> No Items to pay for </td> </tr> <tr align="center"> <td align="left" class="innertablestyle"><font class="normal"> You do not have any items to pay for. </font></td> </tr> </table> <?php /////////////////////////////////////////////////////------------------------------------------ } //end else i.e. no transaction found ?></td> </tr> <tr> <td align="center"> </td> </tr> </table> </div></td> </tr> </table></td> </tr> <tr> <td valign="top"> </td> </tr> </table> What you say thats messy, should I just scrap it and start again?
  19. Sorry Ive been stuck alot the last few days. I have some code that counts my array thats working fine and Ive been running various functions using it. This is working: $countseller=array(); while($rst) { $seller_id= $rst["seller_user_id"]; $countseller[]= $seller_id; $countarray = array_count_values($countseller); if ($countarray[$seller_id] == 1 ){ DO WHAT I NEED TO DO WORKS FINE } if ($countarray[$seller_id] > 1 ){ DO WHAT I NEED TO DO WORKS FINE } Right now what I want to do is ask: IF ($countarray[$seller_id] (IF IS IS THE LAST SELLER_ID IN THE ARRAY){ THEN DO WHAT I NEED TO DO } Is that possible or is that a no go? Im thinking its a no go as Its in a while loop so I guess the code cant look ahead to something that hasnt been written Is there away around this?
  20. ok not to worry Ive fixed it. Thanks for the help I used this: $result="SELECT sum(total) as total FROM my_table WHERE seller_id=".$seller_id; $php = mysql_query($result); if ($php) { $row = mysql_fetch_array($php); echo $row['total'];
  21. Im getting 'Resource id #218' instead of the result
  22. hum its still not working, the results are in decimals eg: 2.00, 4.00 etc Might that be the problem?
  23. I want to add up some totals from a mysql column and output them onto a php page. something like this $total=mysql_fetch_array(mysql_query("SELECT sum=+(total) as total FROM my_table WHERE seller_id=$seller_id")); echo $total; I know thats completely wrong! its just for examples sake. If someone could help me with the right syntax that would be great. Emma
  24. Yay I fixed it!! $countarray = array_count_values($countseller); if ($countarray[$seller_id] >1 ){
  25. I'm still having issues with this array. Ive added a new topic as the needs have changed since I first posted. My array is in a for loop and every time it loops it adds a new value. I want to look into the array and if the value is duplicate then I want to 'do something' Ive added a count_array_values function to the array and thought it would be as simple as >1 but it seems not. This is driving me mad! This is what my array looks like after the count_array_values and this is the code for the array: <? while($rst) { $seller_id= $rst["seller_user_id"]; $countseller[]= $seller_id; if ((array_count_values($countseller)) > 1){ ?> Do What I need to do here <? }else{ ?> Do What I need to do here <? } }// end while ?>
×
×
  • 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.