Jump to content

eves

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Everything posted by eves

  1. do this to your select box [code] <select name='cmbSelect'> <?php      $sel_options = ""; $result = mysql_query("SELECT dept_id, department FROM tbl_departments ORDER BY department ASC "); while ($row = mysql_fetch_assoc($result)) {     $selected = "";     if ($dept_ds[$ctr]==$selectedDepartment) $selected = " selected ";     $sel_options .= "<option value='".$row['dept_id']."' $selected>".$row['department']."</option>";     } echo $sel_options; ?> </select> [/code] just made up the fields on the SQL above, what it does is it selects the previously chosen department
  2. use str_replace to deal with variations of [mytag] something like [code] $open_tag = "[mytag]"; $close_tag ="[/mytag]"; $str = "blah blah blah [mytag] info needed 1 [/mytag]blah blah blah[mytag]info needed 2[/mytag]blah blah blah[mytag]info needed 3[/mytag] blah blah blah"; $var_open = array('[MyTag]','[myTag]','[MYTAG]');// include other variations $var_close = array('[/MyTag]','[/myTag]','[/MYTAG]');// include other variations $limit = count($variations); for($ctr=0;$ctr<$limit;$ctr++) {    $str = str_replace($variations[$ctr],$open_tag,$str);    $str = str_replace($variations[$ctr],$close_tag,$str); }   [/code] then use explode to separate into chunks, retrieve the text in between the tags edit them, then use the implode function to join them up something like: [code] $str_temp = explode('[mytag]',$str); $ret_val = ""; $limit = count($str_temp); for($ctr=0;$ctr<$limit;$ctr++) {     if (strpos($str_temp[$ctr],$close_tag)===false)     {         $ret_val .= $str_temp[$ctr];         }     else     {         $tmp = explode($close_tag,$str_temp[$ctr]);         $tmp[0] .= '(edited)'; // do your edit part here, $tmp[0] contains the text between the tags         $ret_val .= $open_tag . implode($close_tag,$tmp); //join them up, append the open tag at the beginning     }     } [/code] hope that helps
  3. SELECT * FROM mydb WHERE (Goods='lappy' OR Date LIKE '%25') AND (Dept IS NOT NULL OR Dept!='')
  4. you might want to check for the following: 1. FORM method is POST and not GET 2. select box is named "cmbSelect" (I know, but just in case ;]) 3. say you have this links to move to the next page: Page 1 2 3 4 ..... do you link them as <a href='<?echo $_SERVER["PHP_SELF"]."?page=$ctr"?>'> if yes, then your passing your next page in a query string, so test for it using GET something like [code] $selectedDepartment = 1; // default value if ($_SERVER['REQUEST_METHOD']=='POST' && isset($_POST['cmbSelect'])) {    $selectedDepartment = intval($_POST['cmbSelect']); } elseif ($_SERVER['REQUEST_METHOD']=='GET' && isset($_GET['page'])) {    $selectedDepartment = intval($_GET['page']); } if ($selectedDepartment ==0) $selectedDepartment = 1; //just in case something went wrong above [/code]
  5. the problem probably lies on the part where you populate $list[] you might want to post that
  6. [code] $result=mysql_query($query); [/code] you missed that part
  7. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] According to that it means that using $_SESSON['variable'] or $_REQUEST['variable'] should have the same affect [/quote] this is incorrect, the $_REQUEST only consist of the contents of $_GET, $_POST, and $_COOKIE this will never be true: $_SESSON['variable'] == $_REQUEST['variable'] (unless of course, they change the implementation on PHP [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] ) for getting the value of the game id, test for the variable if it is set and has something on it, something like this: [code] if ($_SERVER['REQUEST_METHOD']=='POST' && isset($_POST['game_id']) && trim($_POST['game_id'])!='') {     //just included the strip_tags() to clean posted entry     //you might    want to add some more     $game_id = strip_tags($_POST['game_id']); } else {     $game_id = $_SESSION['game_id']; } [/code]
  8. [code] $result = mysql_query("SELECT rate_1, rate_2, rate_3, rate_4, rate_5 FROM (TABLE) WHERE (CONDITION)  "); $row = mysql_fetch_row($result); // use mysql_fetch_row to get an array with a numeric index // get the max value in the fields (rate_1, teate_2, rate....) and search for it in the array $row // array_keys will return an array based on the search made, thus you access it as $index[0] $index = array_keys($row,max($row)); //determine which field is the highest //order on this part depends on the order of the fields in the select query switch ($index[0]) {     case 0:         //rate_1 is the highest         break;     case 1:         //rate_2 is the highest         break;     case 2:         //rate_3 is the highest         break;     case 3:         //rate_4 is the highest         break;         default:         //rate_5 is the highest         break; } [/code] hope that helps
  9. [code] $words = array("zero","one","two","three","four","five","six","seven","eight","nine"); echo $words[rand(0,(count($words)-1))]; [/code] store some words on an array, then just generate a random index from zero to max index of array ( (count($words)-1)) )
  10. [code] $updateyourstats="update km_users set skillpts='".($skillpts+$ptsgained)."',honor='".($honor+1)."',curexp='".($curexp+100)."' where playername='$player'"; [/code] do that with the other query too.
  11. can you post the codes on the page where it is posted from? also you might want to check if the checkbox is named as "Name[]"
  12. check the manual: [a href=\"http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server\" target=\"_blank\"]http://www.php.net/manual/en/reserved.vari...ariables.server[/a]
  13. are you only using a single table (lyricstable)? if yes, you should normalize it first before proceeding if not, please post the structure of the other tables
  14. you might want to try these: assuming you have this fields on your cart table tbl_cart(cart_id, prod_id, qty, unit_price, pri_shipping, sec_shipping, initial, client_id) - would greatly ease computation if you store primary and secondary shipping on the table - pri_shipping - primary shipping cost of product - sec_shipping - additional shipping cost of product [code] $result = mysql_query("select * from tbl_cart where client_id='$CLIENT_ID'"); $shipping = 0; while($row=mysql_fetch_assoc($result)) {     if ($row['qty']>1)       {         if ($row['initial']==1) //get primary shipping cost first then add secondary costs         {             $shipping += $row['pri_shipping'];             $shipping += ($row['qty']-1)*$row['sec_shipping'];         }         else         {             $shipping += ($row['qty'])*$row['sec_shipping'];         }                }     else     {                 // since only 1 qty, should be the main product, thus primary shipping cost apply         $shipping += $row['pri_shipping'];              }          } [/code] the initial field is etheir 1 or 0, 1 if its the main product being pruchased, else 0 you might want to check for some syntax or typos, just basically made it up on this site's editor [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] hope that helps
  15. [!--quoteo(post=376014:date=May 22 2006, 08:33 PM:name=karl19)--][div class=\'quotetop\']QUOTE(karl19 @ May 22 2006, 08:33 PM) [snapback]376014[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]<a href="#" onclick="mooShows['myShow'].jumptoImage(4);"/a>[/code] [/quote] couldn't really understand the code you provided but here's a shot of what I think your trying to do [code] $limit = 10; //total number of images for($ctr=0;$ctr<$limit;$ctr++) {    echo "<a href='#' onclick='jumptoImage($ctr,'".mooShows['myShow']."');'><img src='".$image[$ctr]."' height=100 width=100></a><br>"; } [/code] the jumptoImage() javascript function take 2 parameters, first a counter that will serve as an indentifier for the image and second, the name of the page that will be opened. I'm just assuming that you would be opening mooShows['myShow'] in a new page or a pop up
  16. do the tables have a common relationship? if not it would be better to create a new table just for tracking the updates, here's a sample structure: tbl_updates - update_id - auto-increment - link_id - store Primary Keys of tables on this field, wether its on reviews, interview or others - type - type of update, review, interview, etc... - tstamp - well, a timestamp store updates on this table and just sort them by the tstamp field during retrieval and use the link_id and type fields to link them to their details hope that helps.
  17. too general, but here's some algo you can use: 1. keep track of starting time, store it on DB 2. convert to timestamp and check difference of current time and starting time 3. if less than 1 hour, skip update 4. if more than or equal to 1 hour, increase value by 10, set starting time to current time, then update the fields on the database
  18. Check for the RSS of the site, big sites usullay have that, you can already feed it to flash since its already in XML format. here's an info on RSS: [a href=\"http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html\" target=\"_blank\"]http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html[/a]
  19. eves

    To a FILE

    wrap your sql query in a function and use this in all your queries inside the function, perform the query, then test if there were any errors then log them [code] function db_query($qry) {     $result = @mysql_query($qry);     if (mysql_errno() > 0)     {         // log error to file here         // and/or perform some error handling         // you can be creative on this part but be wary of some overheads     }              return $result;          } [/code]
  20. Are you trying to dynamically change the path of the form when the user checks the checkbox? say, If the checkbox is checked, form will submit to page A, else submit to page B? If yes, use JavaScript (client-side) if not, is the page submitted from another file? try these: [code]if (isset($_POST['checkbox']) && intval($_POST['checkbox'])==1)[/code]
  21. 1. on your first post, there is something wrong with the line [code]$result = @mysql_query($query);[/code] can't find value for your $query variable 2. check for authorization first before performing anymore actions to avoid wasting resources 3. try this one out: [code] //check for authorization first // if not authorized, redirect or display a message or something $sql ="select image, prodName ,price  from product where dept = 'ladies'"; $result = mysql_query($sql,$conn) or die(mysql_error()); if (mysql_num_rows($result)>1) { echo'             <h1><font color="#FF6600"><center> Ladies Wear</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>                                               </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><td align="center"><b>'.$row['prodName'].'</td></b> <td align="center"><b>€'.$row['price'].'</td></b> </tr>'; } echo'</table>'; } [/code] didn't check for typos, you might want to double check that. Hope that helps.
  22. [!--quoteo(post=367310:date=Apr 21 2006, 03:58 PM:name=Richard181)--][div class=\'quotetop\']QUOTE(Richard181 @ Apr 21 2006, 03:58 PM) [snapback]367310[/snapback][/div][div class=\'quotemain\'][!--quotec--] like i got this cript that i put in a index page and with subdirectories full of pictures and the scrip take the subs and make then i'm not galleries and when you click on one you see all the pictures inside.. what i meanly want to do is how do i call for pictures.. because i don't understand this one bit define('PATH', str_replace('\\', '/', getcwd())); thats the patht hat look for all the pictures i guess i don't know :( [/quote] getcwd() - get current working directory function, it just returns the path of the file and replace any forward slashes with backslashes and places the value in the defined variable PATH. eg: your file is located in say: "public_html/gallery/", this value is stored on the PATH variable and is used to display the images on other lines of code. My guess is placing the file to where your images are will solve the problem or just change the 2nd parameter of define() to the path of your images. Hope that helps.
  23. and don't use include() or include_once() inside conditions, use require() or require_once(). Includes don't work with conditions, require() does
  24. remove any spaces or line breaks before the <?php tag in checklogin.php (line 1)
  25. Hi, that single line of code does not expain everything but here goes: $VAR[4] is an array, and on it just takes any values you assign to it. I'm guessing that the line is just for initialization of a config or something. Writing to the cookie does not happen here but on some other line, it just sets the value to the array and write its content later on to the cookie, try searching for "setcookie(", its the actual function that writes the contents of the variable to the cookie. Your other question, if is $VAR a global variable, depends on where you find that line, if it is outside any function or class, it is a global variable, and also, if your PHP ini's global variable is set to YES, then its definitely global. hope that helps.
×
×
  • 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.