ejaboneta
-
Posts
168 -
Joined
-
Last visited
Posts posted by ejaboneta
-
-
perfect! You have no idea how excited I am right now haha! Thanks to you both! I think I understand joining a little better now.
-
Ok so I think I need something like a WHERE clause before joining.....
This doesn't work
SELECT q.id, q.question, r.answer, r.user FROM poll_questions q WHERE r.user = 0 LEFT JOIN poll_responses r ON q.id = r.poll
and adding it to the end, just selects the rows from the combined table.
SELECT q.id, q.question, r.answer, r.user FROM poll_questions q LEFT JOIN poll_responses r ON q.id = r.poll WHERE r.user = 0
-
I should mention I'm somewhat of a beginner. I understand the sql and I modified it to fit my database but it looks like the r.user=0 takes out all the Null values which is the opposite of what I want... And besides that, questions may be answered by other users so the r.user column isnt always going to be null.
But thanks for the help. I'm gonna play around with it to see if I can come up with something.
SELECT q.id, q.question, r.answer, r.user FROM poll_questions q LEFT JOIN poll_responses r ON q.id=r.poll WHERE r.user=0 AND r.id is NULL ORDER BY q.priority
-
Oh yea, version 4.1.....
and heres an example.
under the questions table:
id question priority
1 Favorite Color? 3
2 Favorite Fruit? 2
3 Country? 3
4 Gender? 4
Under Answers:
id question id answer user
0 1 blue 22
1 1 red 4
2 3 US 22
I want the php code and/or query to find questions that user 22 hasn't answered and return one with the highest priority rating. It can find it the other way around, i dont care. So it would find questions 2 and 4 because there is no answers with those id numbers and user 22 and then select question 2 because it's priority is higher.
Maybe I'm just tired, but i dont know how where to start. I have some other columns and tables involved in this problem but this is the basic function i'm working on. I plan on having alot of questions and even more answers, so i'm hoping for a solution that will be fast..
-
so i have 2 tables, one with questions, and one with responses. I don't want users to be asked the same questions twice.
In the response table, there is an answer id, user id, question id and the answer.
In the question table, theres question id, and the question.
I want to pick a question that the user hasn't answered yet. Any ideas?
-
Yea... thats right...
but it works for me. I've been told it shouldn't but my site works fine without the $_GET...
-
I want a link to open in a new window when clicked. Sorry, i didn't mean popups.
Well honestly.... I don't know javascript... so thats why I haven't been using it. But I was thinking some simple html. I haven't tried to open anything in a new window in a really long time, so I tried <a target="_blank"> and it works in IE but not Firefox.
I'll try using javascript.
-
Ask.com uses iframes to get the result to load under their site. If you notice the title of the page and the url are not of the search result.
With php you could do something like
<a href="http://yoursite.com?url=http://blogurl.com">Link</a>
and on the display page
<iframe src="<?php echo $url; ?>">
-
Seems like it'd be simple but I can't get a link to pop up in its own window in firefox. How can I do it?
-
Try this. I forgot the <tr></tr> tags for the questions...
<?php ### GET PAGE ### if(isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $tolimit = 4; $showend = $page * $tolimit; $showstart = $showend - 4; ### GET TOPICS ### $getthreads="SELECT * FROM forumtutorial_posts WHERE parentid ='0' ORDER BY parentid DESC LIMIT $showstart, $tolimit"; $findamount = mysql_query($getthreads) or die (mysql_error());//for showing the four newest posts ### DETERMINE PAGES ### function pager() { $query= "SELECT COUNT(*) as cnt FROM forumtutorial_posts";//efficant way of counting rows $query2 = mysql_query($query) or die (mysql_error());//because we dont want to call it yet we set it to another variable $row = mysql_fetch_array($query2); $num_rows=$row['cnt']; $pagestoshow = floor($num_rows/$tolimit); for ($i = 1; $i <= $pagestoshow; $i++){ print "<a href='index.php?page=$i'> $i </a>"; } } ### GRAB CONTENT ### function grabContent($r) { $answer=$r["answered"]; $title=$r["title"]; $id=$r["postid"]; if ($answer == 0){ $answer = "no"; } else { $answer = "yes"; } print '<tr>'; print '<td bgcolor="#FFFFFF"><div align="left" class="style17"><a href="showquestion.php?page=' . $id . '">' . $title . '</a></div></td>'; print '<td bgcolor="#FFFFFF"><div align="center" class="style17">' . $answer . '</div></td>'; print '</tr>'; } ?> <table width="467" border="0" align="center" cellpadding="5" cellspacing="5"> <tr> <td width="366" bgcolor="#E6E6E6"><div align="left"><strong>Question:</strong></div></td> <td width="85" bgcolor="#E6E6E6"><div align="center"><strong>Answered?</strong></div></td> </tr> <?php while($r=mysql_fetch_array($findamount)) { grabContent($r); } ?> <tr> <td>Page: </td> <td><?php pager(); ?> </td> </tr> <tr> <td bgcolor="#FFFFFF" colspan="2"> <?php if ($session->logged_in){ print 'Have a question you would like answered?, <a href="questionform.php">Click Here</a>'; } else { print 'You must be logged in to ask a question, to log in <a href="login.php">Click Here</a>'; } ?> </td> </tr> </table>
-
everything is working now so I can't really test anything. The site does rely on register globals but the host is supposed to have it on. I suppose I can just forget it until it happens again.
-
I'm not sure what you're looking for. You want a random background image for the whole page? And how does the text relate to the background? Will what text is displayed depend on the background? Or is the text going to be the same?
Anyways... You can't do this with just html. PHP can do it.
-
Your code was pretty confusing so I tried to re-organize it. I hope it works, I would have tested it but I can't use your database and I dont feel like setting up a test. I used a couple functions so that the php doesn't have to be all mixed up in the html.
<?php ### GET PAGE ### if(isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $tolimit = 4; $showend = $page * $tolimit; $showstart = $showend - 4; ### GET TOPICS ### $getthreads="SELECT * FROM forumtutorial_posts WHERE parentid ='0' ORDER BY parentid DESC LIMIT $showstart, $tolimit"; $findamount = mysql_query($getthreads) or die (mysql_error());//for showing the four newest posts ### DETERMINE PAGES ### function pager() { $query= "SELECT COUNT(*) as cnt FROM forumtutorial_posts";//efficant way of counting rows $query2 = mysql_query($query) or die (mysql_error());//because we dont want to call it yet we set it to another variable $row = mysql_fetch_array($query2); $num_rows=$row['cnt']; $pagestoshow = floor($num_rows/$tolimit); for ($i = 1; $i <= $pagestoshow; $i++){ print "<a href='index.php?page=$i'> $i </a>"; } } ### GRAB CONTENT ### function grabContent($r) { $answer=$r["answered"]; $title=$r["title"]; $id=$r["postid"]; if ($answer == 0){ $answer = "no"; } else { $answer = "yes"; } print '<td bgcolor="#FFFFFF"><div align="left" class="style17"><a href="showquestion.php?page=' . $id . '">' . $title . '</a></div></td>'; print '<td bgcolor="#FFFFFF"><div align="center" class="style17">' . $answer . '</div></td>'; } ?> <table width="467" border="0" align="center" cellpadding="5" cellspacing="5"> <tr> <td width="366" bgcolor="#E6E6E6"><div align="left"><strong>Question:</strong></div></td> <td width="85" bgcolor="#E6E6E6"><div align="center"><strong>Answered?</strong></div></td> </tr> <tr> <?php while($r=mysql_fetch_array($findamount)) { grabContent($r); } ?> </tr> <tr> <td>Page: </td> <td><?php pager(); ?> </td> </tr> <tr> <td bgcolor="#FFFFFF" colspan="2"> <?php if ($session->logged_in){ print 'Have a question you would like answered?, <a href="questionform.php">Click Here</a>'; } else { print 'You must be logged in to ask a question, to log in <a href="login.php">Click Here</a>'; } ?> </td> </tr> </table>
-
I understand the differences between how to write html and xhtml but what are the benefits to each?
-
Alright thanks. I read somewhere that if the site doesn't validate, google might throw it out. Is this true?
-
I asked my client if he wanted html or xhtml and he asked... what does google want?
So what does goole like better?
-
Everything was working fine and then suddenly the varibles in the URL were not being passed. I tried creating a test page to test it and it didnt work there either. I emailed my host and they said it was working fine and after that it did. I thought it might be my browser settings and whatnot but then I had other people tell me they experienced the same thing when it was happening to me.
Is there a reason this could have happened? The host said there was no server side reason for it. I just don't want it to happen again.
If I wasn't clear, the script would say <?php echo $a; ?>
The url would be http://site.com?a=hello
and there would be no output.
-
That's what I thought. I made a copy of my index file and named it index2. Its the same css file and the same page.
-
I've been using php to include my css files. I decided to instead link them but when i do, the results aren't the same. Some things aren't working. For example, when i link it, if a tables width or height is set to 100%, it won't work. I even tried putting the height in the actual table but its not working there either. Some of the background colors aren't working as well. Is there a way to fix this or am I going to have to just include it like I have been?
-
Ah, that was it... I didn't know there was a difference between double and single quotes... Can you tell me when each should be used?
-
<?php $to = 'email@address.com'; $subject = 'Form Subject'; $message = 'Contact Name: ' . $_POST['name']; $message .= 'Company Name: ' . $_POST['company'] . "\n"; $message .= 'Email: ' . $_POST['email'] . "\n"; $message .= 'Product: ' . $_POST['description'] . "\n"; $message .= 'Comments: ' . $_POST['body'] . "\n"; $headers = "From: $email"; mail ($to,$subject, $message, $headers); ?>
Thats what I meant.. the \ was taken out of my code. when I use that, I get an email with
"Contact Name: example company\nEmail: name@email.com\nProduct: product1\nComments: here is the commentswhat I want is
"Contact Name: example companyEmail: name@email.com
Product: product1
Comments: here is the comments
-
I'm trying to email a form with multiple lines of information. I want the information included in the body of the message each on its own line. I know its probably really simple but I can't fingure it out. I read somewhere to use \n or \r for new lines but thats not working.
<?php $to = 'email@address.com; $subject = 'Form Subject'; $message = 'Contact Name: ' . $_POST[name]; $message = $message . 'Company Name: ' . $_POST[company] . '\\r\\n'; $message = $message . 'Email: ' . $_POST[email] . '\\r\\n'; $message = $message . 'Product: ' . $_POST[description] . '\\r\\n'; $message = $message . 'Comments: ' . $_POST[body] . '\\r\\n'; $headers = "From: $email"; mail ($to,$subject, $message, $headers); ?>
-
I've gotten alot of work done. I've added a demo "guest" account so you don't have to take the extra 15 seconds to register. Please take a few minutes to go through and it and tell me what you think! Thanks.
I changed hosts....
http://puppylife.freehostia.com
-
Alright I've validated it. I've done it in HTML 4.01 Transitional.... I don't really understand doctypes... Is there any benefit from choosing another?
I'll look into using divs instead of tables... I've always used a combination of divs and tables but those fancy cartoons are telling I shouldn't....
Thanks but I'm sure I can do the graphic design myself.
Mail to web site?
in PHP Coding Help
Posted
Is it possible to be able to send an email to an email address, and have the content of that message show up on a web page? What do I need to look into for this?