Jump to content

ceci

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ceci's Achievements

Member

Member (2/5)

0

Reputation

  1. I found this "https://github.com/mojombo/clippy" Clippy into our site which uses php. The example is written in Rails (Ruby). https://github.com/mojombo/clippy#readme Can anyone help me convert that into php? Here is my attempt but not getting any results. <? if ( ! function_exists('clipit')) { function clipit($var = 'Copy me please') { $clippy_url = '/resources/flash/clippy.swf'; $clippy = <<< EOD <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="110" height="14" id="clippy" > <param name="movie" value="$clippy_url"/> <param name="allowScriptAccess" value="always" /> <param name="quality" value="high" /> <param name="scale" value="noscale" /> <param NAME="FlashVars" value="text=$var"> <param name="bgcolor" value="#FFFFFF"> <embed src="$clippy_url" width="110" height="14" name="clippy" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="text=$var" bgcolor="#FFFFFF" /> </object> EOD; return $clippy; } } ?> Thanks
  2. hi. this is another general question. I need to know if content has been changed or updated. Scenario: there is a Submitter and a Reviewer. Submitter submits articles for review. Reviewer reviews article and suggests changes before being accepted. Submitter makes the changes and resubmits back to Reviewer. I want to show the Reviewer that the suggested changes has been completed by the Submitter. How can I do this? Store the content in two separate tables and count the words on each mysql table? I really have no idea how I can do this effectively. thanks.
  3. yes, it will be on a mysql table. do you have an example to increment the field everytime the message is sent to screen? thanks C
  4. Hi. This is general question but what's the best way to capture if someone has viewed a message or an item? I am working on a project and want to capture if it has been read or not almost like this forum captures how many times it has been viewed. thanks C
  5. sorry i was not clear the first time around. I am looking for the latest item entered from the second table (tableB) using Left Join. so if tableA has 2 items ID itemType 1 shirts 2 pants and tableB has 2 orders for ID 1(shirts); 3 items for ID 2 (pants) id fk_item_id Orders 1 1 red-shirt 2 1 white-shirt /* last_inster_id */ 3 2 small-size 4 2 large-size 5 2 medium-size /* last_insert_id for item ID2 */ I am interested in the last item ordered from tableB. HOw do I get that? In other words I want to do this but in one shot: // First Query $qryResultA = mysql_query("SELECT id, item_id FROM tableA"); While($row = mysql_fetch_array($qryResultA){ // Second Query to get the last item. $getItemsFromTableB = mysql_query("SELECT *, id FROM tableB WHERE fk_item_id = '$row['item_id']' ORDER BY id DESC ") $innerRow = mysql_fetch_array($getItemsFromTableB); }
  6. hi. i have two tables tableA and tableB in a 1-many relationship. I need the last_id from tableB. I tried this but it returns all the items. SELECT last_insert_id(item_id) as 'lastID', a.book_id, a.title FROM tableA a LEFT JOIN tableB b on a.item_id = b.fk_item_id ORDER BY item_id DESC And if I use Limit 1, you guest it, it only returns one. It should return 1 for each item on tableA. How do I do this? Thank you. Ceci
  7. I am trying manipulate multiple rows to add/update/delete database. Right now, the first time it INSERTS all rows correctly. During Update however, it re-enters previous values plus any new rows. How can I stop this behavior? SUBMISSION FORM. <FORM><? php // Make sure the array has items in it. Display it only if there are items. // "$array_items contains items from database. if(count($array_items) != 0) { foreach($array_items as $className => $sub_className){ ?> <tr> <!-- Display Class --> <td rowspan="<?php print $rowspan_no+1; ?>"> <?php print $className; ?> </td> <!-- Display subclass --> <td rowspan="<?php print $rowspan_no+1; ?>"> <?php print $sub_className; ?> </td> <?php foreach($item as $item_key => $item_name){ ?> <?php $m_rows = mysql_fetch_array($m_qry);?> <tr id='r_id<?=++$count?>_box'> <!-- Display the Name --> <td><?php print $item_name;?> <?php // IMPORTANT*** THE NEXT 3 HIDDEN FIELDS ARE TO BE USED TO ADD OR UPDATE NEW ROWS?> // This field contains an ID if there was a previous entry. <input name="main_item_id[<?=$count?>]" type="hidden" value="<?=$m_rows['id']?>" > // This field contains IDs from Database for all rows for data entry. Thus will always have an ID. and an X number of items. <input name="secondary_id[<?=$count?>]" type="hidden" value="<?=$secondary_id?>" > <input name="sub_className[<?=$count?>]" type="hidden" id="uniqueid<?=$count?>" value="<?=$sub_item;?>"> </td> // user will enter data here <td><input type="text" name="duration[<?=$count?>]" value="<?=$m_rows['duration']?>" size="3"></td> // user will enter data here <td><input type="text" name="effect[<?=$count?>]" value="<?=$m_rows['effect']?>" size="3"></td> <td> </td> <?php } ?> </tr> </form> HERE IS MY INSERT and UPDATE code. The first time it INSERTS all rows correctly. During Update however, it re-enters previous values plus any new rows. How can I stop this behavior? // count($secondary_id) represents the number of rows the form has automatically generated. Eg 10 rows. for ($i = 1; $i <= count($secondary_id); $i++) { // check to see if the id exists. if($secondary_id[$i]) { // Presence of 'main_item_id' represents previous entry. if so, update it. if(!empty($main_item_id)){ $qry = "UPDATE table SET effects='$effects[$i]', duration='$duration[$i]' WHERE id='$main_item_id[$i]'"; $result = mysql_query($qry); if ($result) { $count++; } echo $count .' items updated.'; // if no 'main_item_id' exists, then insert. // This is giving me duplicates! Meaning, re-enters whatever was previously entered + the new entries. }else { // there is no 'main_item_id' so Do INSERT. if($duration[$i]){ echo 'insert items'; $count =0; $insert_qry = "INSERT INTO table(duration, effects) VALUES('$duration[$i]','$effects[$i]')"; $result = mysql_query($insert_qry); if ($result) { $count++; } echo $count .' items inserted.'; } } } Thanks again. C
  8. I used your functions and made it work. Thank you everyone! C
  9. I want to be able to quickly do a loop using a simple count like this: for($i = 0; $i < count($items); $i++) { // do things here. } I tried using the unset() function but it does not seem to do anything. for($j=1; $j <= count($items); $j++){ if($items[$j]==NULL){ unset($items[$j]); } } There has to be an easy way to do this.
  10. Hi. echo '<pre>'. print_r($items, true).'</pre>'; The statement above returns the following array: Array ( [1] => 325 [2] => 326 [3] => 327 [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => [12] => ) echo COUNT($items) returns: 12 The count should be 3 not 12. How can I exclude the empty array? thanks
  11. pls disregard this question. i think i resolved my own problem. thanks.
  12. Hi. I have two tables. One table with pain_meds and the other with diabetes_meds. I want to dynamically generate a table that displays a row for each Diabetes med for every pain_med. For example, for the Amaryl diabetes med there are 5 possible pain_meds (oxycode,Vicodin,ultram,morphine) that it interacts with. The same is true for Avandaryl and Byetta. For a better visual I'll try to attach a screenshot of the desired output. mysql> select dname from diabetes_med; +-------------------------------+ | dname | +-------------------------------+ |Amaryl | |Avandaryl | |Byetta | +-------------------------------+ 2 rows in set (0.00 sec) mysql> select drug_name from pain_meds; +------------------------+----------+ | drug_name | +------------------------+----------+ | oxycode | | Vicodin | | ultram | | morphine | +------------------------+----------+ Here is what I got so far but I can't seem to get it to work. I hope you can help me out. Thanks in advance. $diabetes_med = mysql_query("select dname from diabetes_med"); $diabetes_med_results = mysql_query($diabetes_med); $diabetesCount = mysql_num_rows($diabetes_med_results); while($diabetes_row = mysql_fetch_array($diabetes_med_results)){ // put items into an array ... maybe this helps.... $temp_array[] = $diabetes_row['dname']; } // Grab diabetes_meds and display items on first row. foreach($temp_array as $diabetes_drug){ $pain_meds_qry = mysql_query("select drug_name from pain_meds;"); // now lets do the pain_meds while($painmed_row = mysql_fetch_array($pain_meds_qry)) { <table> <tr id='record<?=++$increment?>'> <td> // Try printing the drug name on left-most column eg. Amaryl, Avandaryl...etc print $diabetes_drug; </td> <td> <input name="painmed[<?=$increment?>]" type="hidden" id="painmed<?=$increment?>" value="<?=$painmed_row['drug_name']?>"> <!-- print pain med eg. oxycode, Vicodin, ultram, morphine --> <?=$painmed_row['drug_name'] </td> <td><input type="text" name="effects[<?=$increment?>]" value="" size="3"> </td> </tr> </table> } } } At best this only generates one table regardless of how many diabetes_med are present. [attachment deleted by admin]
  13. Your code will print First Row: Beatles, Love Me Do, Hey Jude, Helter Skelter Second Row: Rolling Stones, Waiting on a Friend, Angie, Yesterday etc. I don't want that. Looks like instead of arrays like this $Rockbands = array( "First Row" => array('Beatles','Love Me Do', 'Hey Jude','Helter Skelter'), "Second Row" => array('Rolling Stones','Waiting on a Friend','Angie','Yesterday\'s Papers'), "Third Row" => array('Eagles','Life in the Fast Lane','Hotel California','Best of My Love'), I might have to create separate arrays for each row so I have more control over it. Right b/c all the arrays belong to the $Rockbands it doesn't seem possible if place an if statement inside of it to only execute the First Row or the Second Row. It prints all the arrays sequentially which is probably how multi-dimentional arrays is supposed to behave.
  14. Well based on the given array, I would like to print only items from that array, say foreach($Rockbands as $key => $val){ if ($key = "First Row"){ echo $val; //print values for this array only. eg. Beatles, Love Me Do, Hey Jude, Helter Skelter // Do not print anything else. }elseifif ($key = "Second Row"){ echo $val; //print values for this array only. eg. Rolling Stones, Waiting on a Friend, Angie, Yesterday // Do not print anything else. } } Because I am inside the foreach() loop my problem is that it prints everything in sequence. At first I thought the if statementwould be able to control this but it does not. Maybe I was erroneously thinking that I could do something similar to this but inside the foreach() loop: <?php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; elseif ($d=="Sun") echo "Have a nice Sunday!"; else echo "Have a nice day!"; ?>
×
×
  • 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.