-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
I saw the part about the passwords, but it didn't mention dbname.
-
I'm still wondering why it works when you don't select a database name.
-
Sorry - that doesn't help me to help you either. Good luck.
-
I've been a programmer for 30+ years - still don't have a structure. Programming is about learning to solve problems in a logical way and writing code in sensible way so that you and others can decipher it in the future. That's about as much structure as one needs.
-
IMHO - as a newbie you should begin by trying simple procedural php and html and SEE how it's done. You have a perfect learning-tool example project in front of you, so just work on the php to generate the page (html) and the php to handle the input and post the data to your db. When you have that working you can then find something else to do (phase 2?) that you can work a class into. Basically, this example doesn't need classes as it is so small and limited. Good luck.
-
You really expect somebody to volunteer to read thru 200+ lines of your code of which we know nothing and try to 1) figure out what it's supposed to do and 2) what it is you want it to do when 3) you don't even know? Usually when people ask for help on a forum they have done their homework and tried to isolate a small are where the problem may be and then clearly stated what is is doing wrong. Can you do that?
-
minor change in my code then. Simply change the starting value of $elem_val and instead of decrementing it, increment instead. Oh - and change the value test at the end of my while to detect if it exceeds your value instead of checking for less than 0
-
Fatal error: Call to a member function add() on a non-object in
ginerjm replied to broxi000's topic in PHP Coding Help
Don't you need to have an instance of produit in order to call the add function in that class? -
Here's my code - similar to psycho's, but different. <? /* spiral.php */ // $num_rows = 5; // user provided values $num_cols = 4; //******************************** $elem_val = $num_rows * $num_cols; // number to begin with // $edges = array('b','l','t','r'); $min_row = 0; $max_row = $num_rows -1; $min_col = 0; $max_col = $num_cols -1; // $e = 0; $ar = array(); $building = true; while ($building) { $edge = $edges[$e]; switch ($edge) { case 'b': { // do a bottom of the grid row $r = $max_row; for ($c = $max_col;$c >= $min_col; $c--) { $key = "R".$r."C".$c; $ar[$key] = $elem_val; $elem_val--; } $max_row--; break; } case 'l': { // do a left side of the grid $c = $min_col; for ($r = $max_row;$r >= $min_row; $r--) { $key = "R".$r."C".$c; $ar[$key] = $elem_val; $elem_val--; } $min_col++; break; } case 't': { // do a top row of the grid $r = $min_row; for ($c = $min_col;$c <= $max_col; $c++) { $key = "R".$r."C".$c; $ar[$key] = $elem_val; $elem_val--; } $min_row++; break; } case 'r': { // do the right side of the grid $c = $max_col; for ($r = $min_row;$r <= $max_row; $r++) { $key = "R".$r."C".$c; $ar[$key] = $elem_val; $elem_val--; } $max_col--; break; } } if ($elem_val <=0) $building = false; $e++; if ($e > 3) $e = 0; } echo "Showing results table for rows=$num_rows cols=$num_cols<br><br>"; $num_rows--; $num_cols--; echo "<table border=1 style='border-collapse:collapse;'>"; echo "<col width=40px><col width=40px><col width=40px><col width=40px>"; for ($r = 0;$r<=$num_rows;$r++) { echo "<tr>"; for ($c=0;$c<=$num_cols;$c++) { $key = "R".$r."C".$c; echo "<td>$ar[$key]</td>"; } echo "</tr>"; } echo "</table>";
-
Is this what you are looking for? Showing table for rows=4 cols=4 10 9 8 7 11 2 1 6 12 3 4 5 13 14 15 16
-
my bad - you saw my original response before I re-read and saw the brace you had. This is now bad: if ($i % 3==0){ if ($i <> 0){ $dyn_table .= "</tr>"; $dyn_table .= "<tr><td>$dynamicList</td>"; } else { $dyn_table .= "<td>$dynamicList</td>";} } $i++;} Try this: if ($i % 3==0) { if ($i <> 0) $dyn_table .= "</tr>"; $dyn_table .= "<tr><td>$dynamicList</td>"; } else { $dyn_table .= "<td>$dynamicList</td>"; } $i++;
-
Actually looking at this code I don't see what is wrong with it, but as someone else pointed out it Is extremely hard to read as you've written it. Personally I detest code that uses more than one set of <? ?> tags, so reading yours is definitely not easy for me. (look up 'heredocs' in the php manual)
-
I gave you the fix to make - two lines, that's all and it works just fine. And I showed you where to place them. What else can I do?
-
Make this change: if ($i % 3 == 0) { if ($i <> 0) $dyn_table .= "</tr>"; $dyn_table .= "<tr><td>$dynamicList</td>"; } else { $dyn_table .= "<td>$dynamicList</td>"; } $i++;
-
Works for me - I added the </tr> tag at the appropriate place.
-
Are you writing a php app to run on the web? If so, an echo works on a phone just like a pc or table. If not, please ignore my response.
-
You never close your row tag in your if where you check how many cols you have posted. if ($i % 3==0) { $dyn_table .="<tr><td>$dynamicList</td>"; } else { $dyn_table .= "<td>$dynamicList</td>"; } You should be issuing a </tr> tag at some point, but you will need to figure out how to avoid the first row starting with one.
-
Oh, alright. My good deed for this day. Your original JS code should look like this - I think. <script type='text/javascript'> function formValidate() { var form=document.forms["myForm"]; var depts = form.getElementsByName["DeptNo"]; if (depts.length > 0) { var dept = depts[0].value; if (dept == null || dept == "") { alert("Dept number missing"); return false; } return true; } else { alert("Dept number missing"); return false; } } </script> I like to break down my code into distinct steps to aid in getting it done right. Once this works, you may consolidate it as you see fit - or not. This should get your js working. Didn't look at the rest.
-
You didn't correct it! Saying good by now.
-
Can we see your new code?
-
Whatever that means..... So - what is happening now?
-
Many people have written that w3schools is not to be trusted. That said - did you cut and paste this code or did you re-type it and make a mistake, because it is incorrect as you've posted it.
-
What is your intent with your if statement? You have a test there and an assignment there. Also what are you trying to reference in your form? You appended a name but your didn't ask JS to getelementbyname(s) so what do you expect to happen there? IIRC you have to use a function call to get an element by name. (I thought I made it clear earlier)
-
I believe your JS is flawed. Turn on your debugging tool (IE - Developer Tools ?) and you should see an error in the if statement (== vs. =) as well as that reference you are trying to build to a named object. Basically - that function is not running.