Jump to content

christa

Members
  • Posts

    74
  • Joined

  • Last visited

Everything posted by christa

  1. here the complete code: //print all comments... while ($row = mysql_fetch_array($result)) { $sql_user = mysql_query("SELECT u.IDuser FROM users u JOIN articles a ON a.IDuser=u.IDuser AND a.IDart=$_GET['IDart'] WHERE u.IDuser=" . $_SESSION['IDuser'] . ""); $row2 = mysql_fetch_array($sql_user); if ($_SESSION['IDuser'] == $row2['IDuser'] ) { $color = "#FFFFFF"; } else { $color = "#FF0000"; } echo '<div id="comment" style="background-color: ' . $color . '">post</div>'; }
  2. hi all, in my blog (made by me, no wordpress or similar) i would want to change the color of comments written by author of article My code is: $sql = "SELECT author WHERE art_id=..."; //print all comments... while ($row = mysql_fetch_array($result)) { if ($_SESSION['ID_user'] == $sql['ID_user'] ) { $color = "#FFFFFF"; } else { $color = "#FF0000"; } echo '<div id="comment" style="background-color: ' . $color . '">post</div>'; } but the code above print all FFFFFF or all FF0000 Where it is wrong? thanks
  3. now it works fine. One question only: if the key search is (example) "House" the code works; if the key search is "house" the code returns: Notice: Undefined offset: 1 in.... line of $back_array = explode(" ", $string_array[1]); Why? there is a case insensitive example?
  4. ok, but how can i extract or print only 50 words before and 50 words after $mykey?
  5. i try this code: while ($row = mysql_fetch_array($result)) { $my_array = explode("$mykey", $row['mytext']); $my_array[0]; $my_array[1]; $front_array = explode(" ", $my_array[0]); $back_array = explode(" ", $my_array[1]); echo $front_array[0] . " <b>$mykey</b> " . $back_array[1]; } but it returns some errors: "Notice: Undefined offset: 1" and without words nor left nor right.
  6. hi all, in mysql, how can i extract 100 words before and 100 words after my search key? example: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla est nibh, mattis eu mattis id, pulvinar eu augue. Duis ut sem nisi. Sed id ante sed orci vestibulum lacinia ac id nibh. Donec cursus, elit eget auctor semper, ipsum eros laoreet quam, nec ullamcorper" vestibulum is my search key
  7. ok. Last question: when i create a table can I omit the value between () or it is required?
  8. i'm not using zerofill, my field is unsigned. plase correct me if I'm wrong: value: 156 field: int(4) unsigned zerofill > value becomes 0000156 field: int(4) unsigned > value is 156 field: smallint(1) unsigned zerofill > value becomes 0156 field: smallint(1) unsigned > value is 156 Right?
  9. hi all, i have a db table with a field INT(4) UNSIGNED autoincrement named "person_ID". The (4) attribute means that i can store up to 9999 values or not?
  10. hi all! i have 2 tables: PRODUCTS id_prod, id_cat, date, prod_name CATEGORIES id_cat, cat_name My goal is obtain the average (day and month) of all products inserted by users in this format: category Hardware: avg daily 20, month 100 category Components: avg daily 2, month 15 and so on. PS: the 'date' field is unix timestamp (int 10). Can you help me?
  11. My db table has 2 fields: ID - Place 1 France 2 Germany My form has 2 text fields: input name=State1 input name=State2 if I digit Italy in inputname=State1 only updates ID 1 if I digit Spain in inputname=State2 only updates ID 2 So, my db table will become: ID - Place 1 Italy 2 Spain
  12. hi my db table has 2 field: ID - Place 1 France 2 Germany My form has 2 text field (printed with while cycle). mysql_query("UPDATE mytable SET Place = '" . $_POST['place'] . "' WHERE ID=". $_POST['ID']." "); This query doesn't work, because updates only the last record. Where is wrong? many thanks
  13. i tried your code but it prints every number in one line only. I would to obtain this result: 45,3455,66,8900, 2,49,88,8, 909 and so on..... What's not clear?
  14. hi everyone, i have a string as this one: 45,3455,66,8900,2,49,88,8,909 I need to print it with a new line every 4 numbers, as this one: 45,3455,66,8900, 2,49,88,8, 909 How can i do this? many thanks
  15. hi all i would select the 6 records before of my value and 6 record after my value. How can i obtain this result in a single query? thanks
×
×
  • 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.