Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
There is no real right or wrong, but out of the three the first is the worst. The second two are at least clear that there are multiple items. The third is most descriptive depending on what other variables you might have. I think $arrAnswers or $answersArr is kind of annoying honestly but I might be the only one. Actually, all of them are wrong, because you've made them a function using a variable string. Functions end in (), variables start with $. While it's possible to do $answer();, what you're doing is calling a function with the name stored in $answer. So it could be $answer = 'bob'; $answer(); and it would be the same as bob();
-
So is this the code that did not work? What happens when you attempt it?
-
While inside while, needs to be something different
Jessica replied to HCProfessionals's topic in PHP Coding Help
both Psycho and I did address that in the previous post, and I believe he posted an actual example of how to do it. -
Multiple While's, Single Query - Is there a way?
Jessica replied to HCProfessionals's topic in PHP Coding Help
On your last line, you don't need the variable in quotes. I assume the shrug means you didn't get what you expected. you need to provide more info. -
You'll need to post the code for delete.php then. And yes you will need a unique ID.
-
You'd either use AJAX or load a new page.
-
Multiple While's, Single Query - Is there a way?
Jessica replied to HCProfessionals's topic in PHP Coding Help
No, you'll echo it after you've put everything into it. Just try a simple version of your original project. I assume your product has a name, try adding each name to the string $first_html .= " ".$row['product_name']; //Make this the right variable for your db. Then outside of the loop, echo that string. -
Multiple While's, Single Query - Is there a way?
Jessica replied to HCProfessionals's topic in PHP Coding Help
I just realized I was making it even more difficult than it needs to be. <?php $featured_results = mysql_query("SELECT * FROM products LEFT JOIN product_images ON products.product_id=product_images.product_id WHERE products.product_featured='1' AND products.product_active='1' AND thumb='1'"); $first_html = ''; $second_html = ''; while($row = mysql_fetch_assoc($featured_results)) { //Put your HTML into the strings in here. } ?> What are you lost on? Try using this and editing it for your code. you'll also want to turn your SQL into a join at some point, to really cut down on queries. But for now just see if you can get this working. -
Multiple While's, Single Query - Is there a way?
Jessica replied to HCProfessionals's topic in PHP Coding Help
Yes. Here's a bit to get you started. <?php $featured_results = mysql_query("SELECT * FROM products LEFT JOIN product_images ON products.product_id=product_images.product_id WHERE products.product_featured='1' AND products.product_active='1' AND thumb='1'"); $results = array(); while($row = mysql_fetch_assoc($featured_results)) { $results[] = $row; } $first_html = ''; $second_html = ''; foreach($results AS $result){ //Put your HTML into the strings in here. } ?> -
http://php.net/date
-
Multiple While's, Single Query - Is there a way?
Jessica replied to HCProfessionals's topic in PHP Coding Help
Try doing what I said, and I'll help you fix any problems. What I said can be easily converted into psuedo code at least. -
SQL select SUM & For and while loop in a table
Jessica replied to MrCostari's topic in PHP Coding Help
Considering these forums are not supposed to be used to get your homework coded, perhaps you should take your own advice regarding reading. The forum rules also speak about asking for work to be done urgently. Demanding help and calling names is probably the *least* effective way to actually get help. -
Multiple While's, Single Query - Is there a way?
Jessica replied to HCProfessionals's topic in PHP Coding Help
Rather than attempting to query your database twice to get the same set of data, you should select the data out into an array, then loop through the array. You could also avoid doing two loops by having one loop which builds your two different sets of HTML (into strings), then echoing the HTML separately. -
The way you have described makes sense to me. Why don't you try it and see how it goes?
-
Yeah IE does that with the files, I always go and do a shift refresh in Fx. Glad you got it working.
-
If you're talking about in the form, most people would just select the text out of the box and delete it, or you can use the reset. If you're talking about deleting an existing comment, you would delete it from the database. Either way, I don't see anything having to do with delete in your code. When you say you tried it, what did you try.
-
SQL select SUM & For and while loop in a table
Jessica replied to MrCostari's topic in PHP Coding Help
I just asked if you know how to do select and you said yes. Now you say you don't. Maybe this is a language barrier issue, but you're being fairly unclear. You really should talk to your teacher, if you're giving us the true story. -
Multiply Array Values from Multiple Arrays
Jessica replied to unemployment's topic in PHP Coding Help
true, I was just trying to provide a jumping off point. I kind of expected him to come back and go "now how do I do it for more arrays" :-P -
SQL select SUM & For and while loop in a table
Jessica replied to MrCostari's topic in PHP Coding Help
You said in your first post that your queries fail, elaborate. What fails, what error do you get? I don't see any select statements in your posted code, only an insert. -
SQL select SUM & For and while loop in a table
Jessica replied to MrCostari's topic in PHP Coding Help
Start with the first part, selecting the data. do you know how to do SQL queries? -
SQL select SUM & For and while loop in a table
Jessica replied to MrCostari's topic in PHP Coding Help
If I do your homework do I get a gold star on my report card? You need to post a specific problem and question, with specific code. Your request is too general IMO. If you're that concerned about it, go to your teacher and be honest that you need more time and help. -
You'll need to either create it as a javascript function (I have no idea what you're attempting is possible in JS), or use AJAX to submit the code to your PHP page. Either way, you'll need javascript help. The third option I see is instead of doing it onclick, make the page submit, use PHP to clean it up, then refill the form with the corrected content.
-
You're mixing PHP and javascript. They don't work like that.
-
Which browser are you using? Once you have that file open, try a shift refresh while viewing it. I know this is the most frustrating thing with CSS, I've had the same problem.