
cheeseus
Members-
Posts
52 -
Joined
-
Last visited
Everything posted by cheeseus
-
Excellent! Thank you! It is sorted now. I did have two "overflow:hidden" statements in the CSS - one applied to images, and the other was to everything contained in the #body container. Neither of them affected presentation though, they were left over from the old design which I am little by little changing and improving. But the real problem was exactly where you said it was - so I set the #news_archive DIV to float left and the DIV with calendar went into place. Then I set the DIV width to 98% to fill in the entire area and everything looks great! Now to the rest of the appearance
-
Hello, I am not too sure if this is for the HTML or for the CSS section; if Mods think it is for the CSS, please move it. Problem: In this site I am making, I am nesting a table displaying a calendar with a news archive. The table will not show in Firefox (updated to latest version). It shows in Chrome, IE 9, and Opera. It even shows in my phone's browser (Android 4.0)! Both the HTML and the CSS of the site validate, I have examined everything a dozen times, I even inserted <tbody></tbody> tags, which is never do... The table's actual code is there when you look at the page source, it just won't display. I have no idea what is wrong and I hope someone can help me out here. Here's the site: http://amalipe.com
-
Copy single field data from one table to another - help?
cheeseus replied to cheeseus's topic in MySQL Help
RESOLVED: It appears I had to declare the table I was copying the data from in the UPDATE part: -
Copy single field data from one table to another - help?
cheeseus replied to cheeseus's topic in MySQL Help
I also tried this: UPDATE news_text1 SET news_text1.date = news.date WHERE news_text1.parent = news.id I've noticed that whichever column I put after the equal sign is the "unknown column". I guess I'm making some some really stupid mistake or some is broken in my PhpMyAdmin. ... Help please! -
Copy single field data from one table to another - help?
cheeseus replied to cheeseus's topic in MySQL Help
I tried this to test how this thing works (first time ever I need to copy data from one table to another). So, now I tried this: INSERT INTO news_text (date) SELECT news.date FROM news This is supposed to copy ONLY the "date" field, isn't it? Now, it copies ALL the fields of that table. Am I writing this correctly? EDIT: Did some more reading and decided to try this: UPDATE news_text1 INNER JOIN news ON news.id = news_text1.parent SET news_text1.date = news.date This gets executed but "0 rows are affected". -
Copy single field data from one table to another - help?
cheeseus replied to cheeseus's topic in MySQL Help
It does exist. I wouldn't be asking a question here if I wasn't sure it exists and yet I get this mistake. -
Hello, I am trying to copy the data from one of the columns of a table to a column of the same name in another table but can't seem to make it work. The two tables have a different structure. I am trying to copy the "date" field from "news" into the "date" field of "news_text". INSERT INTO news_text (news_text.date) SELECT news.date FROM news WHERE news_text.parent = news.id I get the following error: The "news.id" field corresponds to the "news_text.parent" field. I can't figure out what I am missing :-\
-
Fckeditor empty non-editable textarea when on Wampserver
cheeseus replied to cheeseus's topic in PHP Coding Help
Problem solved. I don't know how. I switched to PHP 5.2.5 a couple of times. Clicked through the different menu items for editing, e.g. News, Programs, Projects, and when I returned to News, the textarea suddenly became editable. I then switched back to PHP 5.3.0 and it was still editable. I will not close the topic as Solved yet, because the problem is unknown and will appreciate any comments that may help me, or other users who happen to encounter this problem. -
Hello, I have encountered a problem and I am not even sure it's stricty PHP-related. The problem is with website I want to migrate to a better hosting provider and I also have to edit the code to make it PHP 5 compatible. I have a news editing panel that uses FCKEditor. There are 3 fields: date, news title, and news text. The first two are OK, but the textarea is empty and non-editable, i.e. I cannot click in it to put the cursor inside. The problem only exists on my local Wampserver (PHP 5.3.0). When I upload all the files to the old hosting server (PHP 5.2.5) the textarea is editable. Here is the code that loads the news editing page: <?php class page extends admin{ function page(){ if(isset($_GET['do'])) { if($_GET['do']=='del'){ mysql_query("DELETE FROM news WHERE id = '$_GET[id]'"); mysql_query("DELETE FROM news_text WHERE parent = '$_GET[id]'"); $this->loc("?nav=news"); } if(!empty($_POST['date'])){ $sql="UPDATE news SET ".$this->post_insert(array("date"))." WHERE id = '$_GET[id]'"; mysql_query($sql); echo $sql; $parent=$_GET['id']; //insert lang values $this->update_langs("news_text",array("name","content"),$parent); $this->loc(); } } } // Sub menu Buttos var $sub_menus=array( array("Списък новини","news"), array("Добави новина","add_news") ); //Sub menu generation function sub_menu(){ for($i=0;$i<sizeof($this->sub_menus);$i++){ echo "<li><a href=\"?nav=".$this->sub_menus[$i][1]."\">".$this->sub_menus[$i][0]."</a></li>"; } } // Language form template function lang_form($name,$id){ echo ' <fieldset> <legend>'.$name.'</legend> <div class="line"><label>Име: </label> <input name="name_'.$id.'" class="text" style="width:450px;" value="'.$this->get_sql_value("SELECT * FROM news_text WHERE parent='$_GET[id]' AND lang='$id'","name").'" type="text" /> </div> <div class="line"><label>Съдържание: </label></div>'; $oFCKeditor = new FCKeditor('content_'.$id); $oFCKeditor->BasePath = 'includes/fckeditor/'; $oFCKeditor->Height= '500px'; $oFCKeditor->Value= $this->get_sql_value("SELECT * FROM news_text WHERE parent = '$_GET[id]' AND lang='$id'","content"); $oFCKeditor->Create(); echo' </fieldset>'; } } $p=new page(); ?> <div id="left"> <ul> <li><h1>Опции:</h1></li> <?php echo $p->sub_menu(); ?> </ul> </div> <div id="center"> <h1>Amalipe.com / Администрация / Новини / Редакция на новина</h1> <form name="add" id="add" action="" method="post"> <fieldset> <legend>Основна информация</legend> <div class="line"><label>Дата: </label> <input name="date" class="text" type="text" value="<?php echo $p->get_value("news","date"); ?>" /></div> </fieldset> <?php $p->lang_forms(); ?> <input value="Промени" class="btn" type="submit" /> </form> </div> The encoded characters you see in the code are Cyrillic names. At first I thought this had something to do with the FCKEditor version so I upgraded it to the last one (FCKeditor_2.6.6) but nothing changed. On my local Wampserver I have two PHP versions - 5.2.9-2 and 5.3.0 - neither works. I have also added 5.2.5 to see if this changes anything but no, it doesn't - the textarea is still empty and non-editable. I hope I can get some help!
-
Strange undefined variable and undefined index notices
cheeseus replied to cheeseus's topic in PHP Coding Help
You're right, I don't need that function for error reporting outside the form check script. I have done it as you suggest, much easier indeed. What I'm working on is a system for my own use that will not go online, so detailed error reporting is unnecessary. Thank you all for your help! -
Strange undefined variable and undefined index notices
cheeseus replied to cheeseus's topic in PHP Coding Help
Thank you! I wrote isset checks for every array I create and got rid of all the warnings Now, the session... Yes, I am concatenating it. That's the way I decided to get all the missing post values after submitting the form and display them - by storing the errors array in a session. Maybe that's not a very good idea then? But, if I stick to this way of displaying error feedback, how do I collect all the missing $_POST values AND get rid of the warning? I tried adding a line where I create an index value, to which to add the $err_messages but this way only the first of the missing fields is printed (and no warning). function formError($err_message) { $_SESSION['errors'] = "fields: "; if(isset($err_message)) { $_SESSION['errors'] .= $err_message.", "; } } -
Strange undefined variable and undefined index notices
cheeseus replied to cheeseus's topic in PHP Coding Help
OK, and how do I define an array key? By declaring an empty array before I start filling the array? (this doesn't work) :-\ $income[] = array(); $income[$client][$currency] += $client_sum; And is this the same situation: When validating a form, I check if $_POST[] is empty. If empty I call an error display function: if(empty($_POST['country'])) { formError("Country"); } ..... function formError($err_message) { if(isset($err_message)) { $_SESSION['errors'] .= $err_message; } } Here I get an undefined index notice for the $_SESSION value: "Undefined index: errors... " -
Strange undefined variable and undefined index notices
cheeseus replied to cheeseus's topic in PHP Coding Help
I have fixed this error - turns out the notice appeared because I had a clientname but no projects and no currency were added for the client. Now that the variable is not empty, it's OK. However, I have the same kind of notice on another page. Now that all variables have a value, I don't understand what else is wrong. As I posted earlier here, this is where I get 12 x 3 notices of undefined indexes (because there are 12 clients in the DB): $income_total = calculate("income"); foreach($income_total as $row) { $clientID = $row['clientID']; $clientname = $row['clientname']; $client = "<a href=\"index.php?page=Project&do=view&sortby=$clientID\">".$clientname."</a>"; $currency = $row['currency']; $client_sum = $row['client_sum']; $year_sum = ''; $year_sum += $client_sum; $income = ''; $income[$client][$currency] += $client_sum; $income_list = statistics($income); $income_all = ''; $income_all[$currency] += $client_sum; } The calculate("income") function returns the results expected, which I fill in the $income_total array that I then break into separate values. The "bad" line is this: $income[$client][$currency] += $client_sum; But the variable $client gets a value, so it's not the first time I declare it. At first I thought it could be because $client contains HTML + $clientname, but when I changed it to $income[$clientname][$currency] += $client_sum; and comment out the line where I assign a value to $client, I still get the same notice, on the same line. What puzzles me is that the notices have the actual clientname/currency name as a undefined index, e.g. Please help me comprehend this. -
Strange undefined variable and undefined index notices
cheeseus replied to cheeseus's topic in PHP Coding Help
OK, I will try to write proper code and to do that I need to know what I'm doing wrong. Is it the same kind of mistake here (this is the complete file). I get two notices about the same undefined variable $currency on line 44: <td>".$currency."</td> here: <?php $list = "<table> <tr><td colspan=\"6\"><h3>Client List</h3></td></tr> <tr> <th>ID</th> <th>Name</th> <th>No. Projects</th> <th>Revenue</th> <th>New</th> <th>View all</th> </tr>"; $client_list = showClients(); foreach($client_list as $row) { $clientname = $row['clientname']; $clientID = $row['clientID']; $client_work = showClientWork($clientID); $np = 0; foreach($client_work as $row) { $projectname = $row['projectname']; $projecttype = $row['projecttype']; $sourcelang = $row['sourcelang']; $targetlang = $row['targetlang']; $totalprice = $row['totalprice']; $subprice = $row['subprice']; $currency = $row['currency']; $paid = $row['paid']; $np += 1; } $list .= "<tr> <td><a href=\"index.php?page=Client&do=edit&clientID=$clientID\" title=\"EDIT $clientname INFO\">".$clientID."</a></td> <td><a href=\"index.php?page=Client&do=edit&clientID=$clientID\" title=\"EDIT $clientname INFO\">".$clientname."</a></td> <td>".$np."</td> <td>".$currency."</td> <td><a href=\"index.php?page=Project&do=new&clientID=$clientID\" title=\"New Project for ".$clientname."\"> <img src=\"images/add.gif\" alt=\"add.gif\" border=\"0\" /></a></td> <td><a href=\"index.php?page=Project&do=view&sortby=$clientID\" title=\"All projects by ".$clientname."\"> view all</a></td> </tr>"; } $list .= "</table>"; echo $list; ?> $currency gets its value above, in $currency = $row['currency']; And, what about the "undefined index" issues? -
Hello, I have just upgraded my wampserver and with it MySQL, PHP and PhpMyAdmin versions. And my scripts, which ran normally before, not burst hundreds of undefined variable and undefined index notices. I realize it's "notices", not "errors" but this is quite irritating. I believe it might be due to some upgrade in PHP scripting rules or something but I don't know what. I hope you can help me. The first type of notice is "undefined variable". This function will return the notice if I remove the bold red line, where I define the variable as empty before I use it in the loop. I didn't need to do this before. function statistics($array) { [color=red][b]$list = '';[/b][/color] if(is_array($array)) { foreach($array as $name => $value) { // Rip out the name of the client. $list .= "<li>".$name." - "; // set an integer so we know how many tier2 values we have read. $x = 0; foreach($value as $difference => $sum_total) { // if this is the more than the first tier2 values, use a '+' between the units. $list .= (++$x > 1) ? " + ".$sum_total." ".$difference : $sum_total." ".$difference; } // close the line out. $list .= "</li>"; } } return $list; } To avoid the 10+ like notices on the page I declare them empty before the variable's first occurrence. But this sounds stupid to me. Wasn't this one of PHP's benefits, not to have to declare the variable before using it? I also get about 30+ undefined index notices, e.g. Here are those lines: $income_total = calculate("income"); foreach($income_total as $row) { $clientID = $row['clientID']; $clientname = $row['clientname']; //$client = "<a href=\"index.php?page=Client&do=view&clientID=$clientID\">".$clientname."</a>"; $client = "<a href=\"index.php?page=Project&do=view&sortby=$clientID\">".$clientname."</a>"; $currency = $row['currency']; $client_sum = $row['client_sum']; $year_sum = ''; $year_sum += $client_sum; $income = ''; $income[$client][$currency] += $client_sum; $income_list = statistics($income); $income_all = ''; $income_all[$currency] += $client_sum; } Line 37 is: It's the values assigned to $client and to $currency that seem to cause the notice. How do I deal with this? I don't just want to turn error/notice display off, I want to resolve this issue.
-
Where I wrote "that easy" I mean it does give me the wanted data but not in the way I can further manipulate it. Here's where I am now: foreach($projectDataMulti as $key => $project) { $description = $project['projectname']." - ".$project['projecttype']." from ".$project['sourcelang']." into ".$project['targetlang']; $unit = $project['unit']; $units = $project['units']; $unitprice = $project['unitprice']; $currency = $project['currency']; $totalprice = $project['totalprice']; $clientname = $project['clientname']; $clientid = $project['clientid']; } But these variables ($description, $units...) they are arrays too, aren't they? In the HTML form I print below I need to be able to handle each variable separately, because I need to fill them in their relevant fields. This whole thing is for the part where I want to print an invoice for more than one project at the same time. And in the invoice HTML I have separate "description", "unit", "units", "line total" fields for each project (I calculate "line total" using JS). So my question is, from the above foreach cycle, how do I extract an individual value? Here's my HTML: <tr> <td class=\"input\">1.</td> <td class=\"input\"><input type=\"text\" name=\"description\" id=\"description\" size=\"40\" value=\"".$description."\" /></td> <td class=\"input\"><input size=\"5\" type=\"text\" name=\"unit\" id=\"unit\" value=\"".$unit."\" /></td> <td class=\"input\"> <input type=\"text\" name=\"unitprice\" id=\"unitprice\" size=\"4\" value=\"".$unitprice."\" /> <input type=\"text\" name=\"currency\" id=\"currency\" size=\"4\" value=\"".$currency."\" /> </td> <td class=\"input\"> <input type=\"text\" name=\"units\" id=\"units\" size=\"7\" value=\"".$units."\" /> </td> <td class=\"input\"> <input type=\"text\" name=\"linetotal\" id=\"linetotal\" size=\"7\" onfocus=\"calculate()\" value=\"".$linetotal."\" /> <script type=\"text/javascript\">calculate();</script> <input type=\"text\" name=\"currency\" id=\"currency\" size=\"4\" value=\"".$currency."\" /> </td> </tr> Do I need to put this HTML inside the foreach loop, or should I better 1. count how many times the foreach loop is iterated. 2. assign a value to each of the iterated variables, e.g. $description[0], $description[1], ... (which I am not too sure how) 3. print these values in the HTML. Hope my explanations aren't too obscure. Thanks for your help!
-
I don't feel particularly clever... It can't be that easy: echo $value['projectname']." - ".$value['sourcelang']." - ".$value['targetlang']."<br />";
-
Oh, seems I haven't figured it out completely. Now ... how exactly do I print an individual value? I was misled by what I printed above as a preview result, using this: foreach($projectDataMulti as $key => $value) { echo $key.": "; foreach($value as $iKey => $iValue) { echo $iKey." - ".$iValue.", "; } } Here's the preview: 37: projectname - XXXXX, projecttype - translation, sourcelang - BG, targetlang - ENG, units - 1267... 35: projectname - YYYYY, projecttype - translation, sourcelang - BG, targetlang - ENG, units - 11000... But I can't access an individual item of the results, e.g. projectXXXXX's source and target languages.
-
Worked right out of the box! Thank you very much! I think what I am missing on arrays is this part exactly - multidimensional arrays (still learning). I will try to comprehend it. Was there a way to get the same results out of the mess I'd done? Here is how I received my results before: <pre> projectID: 0 - 37, 1 - 35, projectname: 0 - XXXXX, 1 - YYYYY, projecttype: 0 - translation, 1 - translation, sourcelang: 0 - BG, 1 - BG, targetlang: 0 - ENG, 1 - ENG, units: 0 - 1267, 1 - 11000, unit: 0 - words, 1 - words </pre>
-
Hello, I don't seem to be able to get the hang of arrays, multidimensional ones in particular and I need some help printing this one here. First, I get the data from the DB by querying it as many times as projectIDs I send. foreach($projectIDs as $row => $value) { $query = mysql_query("SELECT * FROM ".PROJECT_TABLE." WHERE id = '$value' "); $row = mysql_fetch_array($query); $projectID[] = $row['id']; $projectname[] = $row['projectname']; $projecttype[] = $row['type']; $sourcelang[] = $row['sourcelang']; $targetlang[] = $row['targetlang']; $units[] = $row['units']; $unit[] = $row['unit']; $unitprice[] = $row['unitprice']; $currency[] = $row['currency']; $totalprice[] = $row['totalprice']; $clientname[] = $row['clientname']; $clientid[] = $row['clientid']; } $rows = array( 'projectID' => $projectID, 'projectname' => $projectname, 'projecttype' => $projecttype, 'sourcelang' => $sourcelang, 'targetlang' => $targetlang, 'units' => $units, 'unit' => $unit, 'unitprice' => $unitprice, 'currency' => $currency, 'totalprice' => $totalprice, 'clientname' => $clientname, 'clientid' => $clientid, ); Then I get the contents of the queries: $projectDataMulti = invoiceDataMulti($projectID); Now I need to get the contents grouped by projectID and here's where I got stuck. This method does print the results but ont in a way I can further manipulate them, which I need to do before I print them. foreach($projectDataMulti as $key => $value) { echo $key.": "; foreach($value as $iKey => $iValue) { echo $iKey ." - ".$iValue.", "; } echo "<br />"; } I need to get the results in the following manner: projectID0: projectname0 + projecttype0 + sourcelang0 + sourcelang0; projectID1: projectname1 + projecttype1 + sourcelang1 + sourcelang1; etc. so that I can print the relevant values in the relevant fields. Please explain how to do this and why, don't just give me the answer. Thank you!
-
Sorry, it's getting too late and my mind's not working. The second solution worked "out of the box" THANK YOU. Will try to comprehend the way it works.
-
Well, obviously I'm not getting it. Must be something I'm missing. I tried the first suggestion and wrote this: $query = mysql_query("SELECT clientname,units,unit, SUM(units) FROM ".PROJECT_TABLE." GROUP BY clientname,unit "); $rows = array(); while($row = mysql_fetch_array($query)) { $last_client = ""; $units_total = $row['SUM(units)']; foreach($units_total as $units_row) { $clientname = $units_row['clientname']; if($last_client != $clientname) { $rows[] = array( 'clientname'=> $row['clientname'], 'unit' => $row['unit'], 'units' => $row['SUM(units)'], ); } } } But I only get "Invalid argument supplied for foreach()". I tried copy-pasting the second suggestion (as it's more than I can grasp at the moment) but nothing changed.
-
Hello, I am trying to resolve the following issue: I get my results from a MySQL DB as follows: $query = mysql_query("SELECT clientname,units,unit, SUM(units) FROM ".PROJECT_TABLE." GROUP BY clientname,unit "); $row = array(); while($row = mysql_fetch_array($query)) { $rows[] = array( 'clientname'=> $row['clientname'], 'unit' => $row['unit'], 'units' => $row['SUM(units)'], ); } This works fine when for each client if I have only one type of unit for them, but if I have two or more different types of unit, the grouping leaves more to be desired. I print my results as follows: $units_total = calculate("units"); foreach($units_total as $units_row) { $clientname = $units_row['clientname']; $unit = $units_row['unit']; $units = $units_row['units']; $units_all += $units; $units_list .= "<li>".$clientname." - ".$units." ".$unit."</li>"; } And the above prints the same client twice if the unit type is different, e.g. What I'd like to achieve is get the client printed only once but have the different type of units listed after its name, e.g. However, I have little idea where to aim my efforts. Hope someone can help me.
-
Hi everyone, I am trying to install a tabbed panels section on my site where I can display news from different categories, i.e. first query the DB and take out the different categories and write them as the TAB names. Then, with another query, display news from the corresponding category in the corresponding tab. But all I get is the categories and then the news from only one category. Here's the code: <div id="TabbedPanels2" class="VTabbedPanels"> <ul class="TabbedPanelsTabGroup"> <?php $section_query = mysql_query("SELECT * FROM az_sections ORDER BY section_id ASC",$connect); while($row = mysql_fetch_array($section_query)) { echo "<li class='About' tabindex='0'>".$row['section']."</li>"; } ?> </ul> <div class="AboutContentGroup"> <?php $article_query = mysql_query("SELECT * FROM az_articles WHERE issue = 'February 2008' ORDER BY art_id ASC",$connect); while($arow = mysql_fetch_array($article_query)) { echo "<div class='ContentAbout'>".$arow['art_title']." ".$arow['section']."</div>"; } ?> </div> </div> Can anyone help?
-
Thank you, I will try later as it is almost midnight here