-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Ignoring that this forum is a PHP ONE and that you shouldn't have posted this question here, I offer this advice. When you next post this question somewhere, you might want to include the message you received when you ran the validation on it. You might also try and update this very old code (you wrote this a few years ago perhaps?) and use CSS and get rid of the repetitious styling and the deprecated attributes that your very old code is using.
-
Consolidate your connection logic with the handling of the result of that attempt. Don't do the testing in your mainline script - do it in the connect module. Keep like things together. Even better - turn that connect module into a function and then simply include it (require it) at the top and then when you need to make the connection call the function. You could then embed the error output into the function or you could test the function return in the script and output something there instead.
-
submit a form and unset a session variable on other page
ginerjm replied to Cyjm1120's topic in PHP Coding Help
If you have session var such as $_SESSION['cartsubmit'] then to remove it you say unset($_SESSION['cartsubmit']); session_unset would do something you dont' want to do. -
submit a form and unset a session variable on other page
ginerjm replied to Cyjm1120's topic in PHP Coding Help
Perhaps there is some confusion about session vars. A $_SESSION var is accessible from any script running within the same 'session', hence the term 'session var'. So if your script has set a session var, another script that runs after that and opens the same session will naturally have access to the same sesson vars and that script can then unset anything in it -
Combining two arrays into a multi-dimensional array
ginerjm replied to frankchester's topic in PHP Coding Help
I'm always fascinated by the newcomer's attraction to creating complex arrays to handle their data output needs. All that work to create a temporary structure when there is already a very nice structure available that is permanent - the database. Why not focus on writing a better query (probably need a join - read up on them) and in that way obtain your data just the way you need it and then use those results to build your output? -
AND - why do you have this structure in your main code rather than placed inside the function? Wouldn't that make more sense?
-
1 - I never understand why people use function_exists. If you are writing the code, didn't you write that function? So why test for it? 2 - What makes you suspect a problem here? Tell us what happens - or better yet debug your function to see what it is doing (add some echos).
-
I need a grand total of "$Total = odbc_result($result, "total");"
ginerjm replied to kat35601's topic in PHP Coding Help
HTH! -
I need a grand total of "$Total = odbc_result($result, "total");"
ginerjm replied to kat35601's topic in PHP Coding Help
My bad. You have to initialize the var before the loop -
Your query ends with " and duration". The only thing I see there is that it evaluates duration to 'TRUE' and basically anything with a non-zero duration is selected. What are you trying to do with that clause tother than confuse others? As for your output - you are generating a table inside of a table for EVERY row of the results. Why? To get your total, set a var to 0 and then in the loop accumulate the duration into that var each time thru the loop. When the loop ends, output that var .
-
I need a grand total of "$Total = odbc_result($result, "total");"
ginerjm replied to kat35601's topic in PHP Coding Help
Not familiar with the odbc extension but I would guess you get each column in that loop this way: while ($row = odbc_fetch_array($result)) { echo "<tr><td>" . $row['ompCreatedBy'] ."</td>"; echo "<td>" .$row['orders'] ."</td>"; echo "<td>" . $row['total'] ."</td></tr>"; $gr_total = $gr_total + $row['total']; } -
I need a grand total of "$Total = odbc_result($result, "total");"
ginerjm replied to kat35601's topic in PHP Coding Help
From your posted query the part that says " round(sum(SO.ompOrderTotalBase),2) as total " gives you a total of that column for each of the ompcreatedby values. How are you processing the output of your query? In a loop? Don't understand your next comment. -
My question pertained to the fact that your query, as written and posted, would be broken. I know it's a column. Do you know that it's a bad query statement? Do you have any more code to show us or did you look up how to make a query calculate a sum for you?
-
But you asked for 'better'. 'Nuff said. Happy hunting. Bye.
-
I need a grand total of "$Total = odbc_result($result, "total");"
ginerjm replied to kat35601's topic in PHP Coding Help
1 - you can build the total calc into your query statement. Show us your query 2 - you really should grab your results row by row instead of individually by column. It's a waste of resources the way you are doing it. -
Yeah - good luck with that.
-
You keep it the same way you would for any dropdown - you set the 'select' attribute on the pertinent option tag. In your case you would need to re-build the list when you get a selection from the user. As for re-using the saved SESSION var I guess you would have to trash it and re-build it when you get a new selection. And don't say you don't know how - look it up first
-
"AND duration" ??? What is this? And - where is the rest of the code? If you just want a total of duration, add that to the query. Or, if you are going to browse thru the results in a loop, you could just accumulate the value as you go and then output it at the end of the loop (after).
-
My motto is you get what you pay for. That said - I've been useing 123ehost for about 10 years. Full-size plan is $99 a year. Lesser plans are cheaper. They support you and provide a full range of services. Excellent down time stats.
-
Way too much code to look at. Do you really think we need to see the css? How about showing us the part where you build the dropdown? At the completion of that build, save the var that you (hopefully) just built in $_SESSION. Then where you actually output all your html (cause I just KNOW that you didn't dare to do it inside that loop) include that session var. When the page comes back to your script before you start the build next time see if the session var exists. There you go
-
You need to apply some common sense to how you write your code. For example - you begin by moving all of your POST inputs into local vars without looking at them at all. Then you start looking at the POST vars once again to see if you want them. What was the point of grabbing the local vars? Waste of memory resources and computing resources and a contributor to code bloat.
-
Uhhh...... Where's the code?
- 4 replies
-
- insert into
- php
-
(and 1 more)
Tagged with:
-
Updating data not populating from database on to form
ginerjm replied to Vas_ko's topic in PHP Coding Help
If you have a problem - post the relevant code (properly) and tell us the specifics and we'll be glad to help. Giving us some disjoint attachments and a brief and poorly written synopsis of your hopes will not work. -
OR - resend the same form along WITH the results if you don't want to learn how to use JS/AJAX.