Jump to content

ryan.od

Members
  • Posts

    75
  • Joined

  • Last visited

Everything posted by ryan.od

  1. If I want to store email addresses in a db and use a form to send out a bulk email to all stored addresses, can I query the db and put all the addresses in one mail function and seperate each by a comma? RyanOD
  2. Heh, heh, I guess I'm still new to this and didn't catch your little joke. I completely understand what you are saying and it makes complete sense. However, if the form has 5 or 6 fields, am I gaining anything by putting in a hidden field that I can use to check to see if the form was actually submitted? I realize your method accomplishes this, but it makes that check for every form field when really, checking one of them would be sufficient. I guess adding a hidden field wouldn't be much of an improvement. . . How about this. . .would this be considered more 'efficient' or am I splitting hairs?? Thanks again. [code] <?php if(!isset($_POST['email'])) {     if(empty($_POST['email']))     {         // please enter your email !     }else{         // good user :)     }     if(empty($_POST['whatever']))     {         // please enter your whatever!     }else{         // good user :)     } . . . } ?> [/code] RyanOD
  3. If a form is submitted with all the fields left blank, what is sent in the $_POST array? Are all the array values considered to be 'set'? Thanks for the suggestion. Is it a waste of time to check isSet on every form element? How about using a hidden form field with a value of TRUE. Check for that first and if that is OK, then check if each form field is empty or not. I used the aforementioned approach once and it worked well. There are just so many options to do this, I'm not sure which one works best (they all work) and why. Thanks for your input. RyanOD
  4. I am using the following two types of checks for form verification. I am wondering if one is 'better' than the other and, if so, why. Thanks for any insight! #1. . . if(!$_POST['email']) { $errors[0] = 'You forgot to enter your email address.'; } else { $email = trim($_POST['email']); } #2. . . if(empty($_POST['email'])) { $errors[0] = 'You forgot to entry your email address.'; } else { $email = trim($_POST['email']); } RyanOD
  5. You cannot use a left border on the right column or a right border on the left column because there is varying amounts of content in each column and CSS borders only extend down to when the content ends. As such, if you use a left border on the right column and on some page the right column is shorter than the left column, the left border will not reach the footer division. . .there will be a gap. Thanks for pointing out the div issue. I'm developing a full CMS / blog / ecommerce solution for a company in Portland, OR and have yet to slow down to look for issues such as that. I owe you one!! RyanOD
  6. Alright. That works. Really, I was hoping for a CSS border based solution, but using a bg image works fine. Thanks, I wouldn't have thought to try that. Ryan OD
  7. One way would be to put a span class around the second word and apply a left margin to the span class. It works, but I don't know if it will meet your needs.
  8. What you are talking about is a 'hanging indent'. Search the web. There are lots of people trying to solve this issue. I think you can find lots of research on this issue. Ryan OD
  9. I hope I am not insulting you with this solution, but one way to accomplish what I think you are after is to display your text as a block element. Try this. . . [b]CSS[/b] #left{float:left;} #img{float:left;} #text{display:block;} [b]HTML[/b] <div id="left"> </div> <div id="main">     <img src="images/cart_sm.png" />     <div id="text">Hello, this is some text. Hope it works.</div> </div> </body> If you don't want to introduce another division, use <p></p> around your text since paragraphs are block elements be default. RyanOD
  10. If I have a two column layout with varying amount of content in the right division, how do I ensure the border between the left and right division always reaches the cleared footer at the bottom? See it here. . . http://www.evaluationsite.com/login/login.php Currently, the border is a left-border applied to the right column. If I switched the border to a border-right applied to the left column, it would fix the problem. However, as soon as there is enough content in the right column to push the footer down, I have the same problem again. I know this is common issue. . .I just don't know what the answer is. Thanks. Ryan OD
  11. Fantastic! Thanks so much. I was thinking I would reverse the blog order with PHP, not MySQL. RyanOD
  12. Hey, thanks!! Actually, switching to OOP might not be too bad. I studied C++ in college and have a pretty decent understanding of the concept. Yes, pagination is a good thing to think about. I planned on getting to that, but I like your suggestion of putting the entries on seperate pages. Maybe I'll go that route. Once more thing. . .how do I reverse sort my entries based on date? Can rsort be used for this? Thanks again. Ryan OD
  13. I am completely new to PHP and have designed my own CMS with an integrated blog. At this point, the blog just posts the entry along with comments about the entry. I have yet to even create a way for a visitor to enter a comment (getting to that). What I am wondering about is the quality of my coding. I am going to paste my blog code in below. If anyone could look at it and leave some general comments (especially those that point out obvious beginners mistakes), I would be very appreciative. Please try to remember this is the first thing I have ever coded in PHP. Thanks. RyanOD -- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Pod Doctors</title> <link rel="stylesheet" type="text/css" href="css/stylesheet.css"> </head> <body> <?php include ('db/db_connect.php'); include ('db/db_select.php'); $sql = "SELECT * FROM menu"; $result = mysql_query($sql) or die('<p>Unable to perform menu query. Error: ' . mysql_error() . '</p>'); ?> <div id="container"> <div id = "top"> <img src="images/logo.png" /> </div> <div id = "ads"> </div> <div id = "left"> <ul> <?php include ('menu/menu.php'); ?> </ul> </div> <div id = "main"> <div id = "blog"> <?php $sql = "SELECT * FROM blog"; $result = mysql_query($sql) or die('<p>Unable to perform menu query. Error: ' . mysql_error() . '</p>'); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo('<div id="entry">'); echo('<h2>' . $row['blog_title'] . '</h2>'); echo('<p>' . $row['blog_main'] . '</h3>'); echo('<h4>Posted by ' . $row['blog_author'] . ' on ' . $row['blog_date'] . '</h4>'); echo('</div>'); $id = $row['id']; $sql2 = "SELECT * FROM comment WHERE id = '$id'"; $result2 = mysql_query($sql2) or die('<p>Unable to perform comment query. Error: ' . mysql_error() . '</p>'); echo('COMMENTS'); while($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo('<div id="comment">'); echo('<h3>' . $row['comment_title'] . '</h3>'); echo('<p>' . $row['comment_body'] . '</p>'); echo('<h4>Posted by ' . $row['comment_author'] . ' on ' . $row['comment_date'] . '</h4>'); echo('</div>'); } } ?> </div> </div> <div id = "footer"> <p>Copyright xxxxxxxxxx, 2006 | All Rights Reserved | <a href = "#">Contact xxxxxxxxxx</a></p> </div> </div> </body> </html>
  14. How does PHP treat variables? What I mean is, if I set $auth = 1 in one script and then set $auth = 0 in another script, which value does the site recognize as the true value? Is each $auth unique to it's script (local) or are variables in PHP such as the $auth variable I am using global? Thanks. ryanod
  15. Just wondering if anyone can point me to a tutorial or even a discussion of how to create user pages for registered users? What I am shooting for is for each registered user to get their own unique page they can upload images to and generally customize. I realize this is a complicated endeavor and I am new to PHP, but as I work to figure out a way to do this, I was just wondering where I could read about others who have already pulled it off. Thanks for your suggestions / help.
  16. OK, that works. Unfortunately, it escapes all the quotes (great! PHP can handle them) and that is a problem when it is written in as HTML. As such, I guess I need to escape everything so the PHP can read it, then 'unescape' everything when it is written in as HTML. Not sure how this can be done. . . Thanks for your quick response.
  17. How do I put a YouTube embed link into a db and then use php to put the code into the page html? The issue is all the quotes. . .I'm not sure how to deal with them. Manually, I would just use \ to handle the internal quotes. Any suggestions? Here is an example: <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/gZ5Weo7Gqws"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/gZ5Weo7Gqws" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object> I want users to be able to insert these with a form, but when I try to pull them out of the db with PHP, I don't know how to deal with all the quotes. Thanks.
  18. I have a form that targets itself and is used to insert into a db. It works fine, but I want it to insert and then reload the form for another submission (with a little blurb telling them it inserted the last one successfully). Right now it will only do the IF part upon submission rather than the ELSE part. I am currently using the following code. Can I put another copy of the form in the 'IF' part? I tried that and it didn't work. Any suggestions would be appreciated! Thanks, Ryan -- <html> <head> <title>Add New MySQL User</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php if(isset($_POST['add'])) { include_once('db_connect.php'); mysql_select_db ('evaluati_blog'); $query = "INSERT INTO blog_main (title_main, intro_main, content_main) VALUES ('$title', '$intro', '$content')"; $result = @mysql_query ($query); if($result) { echo 'Blog inserted! '; } else { echo 'Sorry'; } include 'db_close.php'; } else { ?> <div id="wrapper"> <form action="blog_submit.php" method="POST"> <fieldset><legend>Article Submission</legend> <div id="main"> <table cellpadding="5" cellspacing="0" border="1"> <tr valign="bottom">   <td width="150" valign="bottom" >   <label for="q8">Title <span class="required">*</span></label>   </td>   <td valign="bottom">   <input type="text" size="40" name="title" id="q8">   </td> </tr> <tr valign="bottom">   <td width="150" valign="bottom" >   <label for="q9">Intro</label>   </td>   <td valign="bottom">   <input type="text" size="40" name="intro" id="q9">   </td> </tr> <tr valign="bottom">   <td width="150" valign="top"  >   <label for="q6">Blog<span class="required">*</span></label>   </td>   <td valign="bottom">   <textarea wrap="soft" cols="30" rows="8" name="content" id="q6"></textarea>   </td> </tr> <tr valign="bottom">   <td width="150" valign="top"  >   <label for="q7">Category<span class="required">*</span></label>   </td>   <td valign="bottom">   <?php     include_once('db_connect.php'); mysql_select_db ('evaluati_blog'); $query  = "SELECT * FROM blog_category"; $result = mysql_query($query);   while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<input type=\"radio\"  id=\"\" name=\"{$row['subject']}\" value=\"{$row['subject']}\">"; echo "{$row['subject']}<br />"; } include_once('db_close.php');   ?>   </td> </tr> <tr valign="bottom">   <td width="150" valign="bottom" >     </td>   <td valign="bottom">     <input type="submit" name="add" id="add" value="Submit">   </td> </tr> </table> </div> </fieldset> </form> </div> <?php } ?> </body> </html>
  19. I thought that was the entire idea behind database normalization. Whenever there is a one-to-many or many-to-many relationship, the designer should break the table up into smaller tables (each with their own primary key) and link them with foreign keys. Initially, I used one table (and everything worked fine). Then, after doing some research about db design, I went back and redesigned my dbs so they satisfied db normalization up to normal level 3. Perhaps I am mistaken, but I was under the impression I was understanding db design pretty well.
  20. Yes, the db structure is attached to this post. Thanks. recordset2 refers to the reviews_link table recordset3 refers to the reviews_post table recordset4 refers to the reviews_category table [attachment deleted by admin]
  21. I'm new to MySQL / PHP and am trying to set up a system where a site visitor can post a recommendation with the following:   - title   - description   - URL link   - category I set up the tables using normalization 1, 2, and 3 techniques. This resulted in the title and description being in one table while the links and the categories were in two different tables that used foreign keys to 'connect' to the main table. My issue is this. I am using Dreamweaver to set up the dynamic side of the site. I expected to be able to create recordsets and  capture the info from the tables and use the 'repeat region' feature to get it to cycle through the tables and get all the info. Unfortunately, the information is nested (I need it to go 'title', 'description', 'link' in that order. DW wouldn't allow that. What technique do I use to do this? I am wondering about the JOIN feature in MySQL. Is it possible to use an INNER JOIN and then work with that table? I'm going to post a chunk of code that represents the area I am talking about. I know it doesn't work right and I understand why. I just don't know what approach will get it to work. Thanks for any and all help. Ryan.OD -- <div id="content_main">     <div class="art">     <?php do { ?>         <h3>           <?php do { ?>             <a href="<?php echo $row_Recordset2['url_link']; ?>">               <?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>               <?php echo $row_Recordset3['title_post']; ?> </a> </h3>     <p> <?php echo $row_Recordset3['intro_post']; ?>             <?php } while ($row_Recordset3 = mysql_fetch_assoc($Recordset3)); ?>     </p>         <?php do { ?>         <h5> <?php echo $row_Recordset4['cat_category']; ?>         <?php } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4)); ?> </h5> </div>   </div>
  22. Nevermind. The problem was that I didn't enclose my FOREIGN KEYS in paranthesis. Duh.
  23. You should look into database normalization (search it) and break this table into multiple tables.
  24. Can anyone tell me what is wrong with this? The reviews_post table and the reviews_post_category table generate an error and I don't know why. Also, the post -> category relationship is many-to-many. As such, I created the reviews_post_category table that only has foreign keys in it that reference the post ID and the category ID in their respective tables. Is this the correct approach? Thanks, Ryan <?php require_once('db_connect.php'); mysql_select_db ('evaluati_reviews'); $sql = 'CREATE TABLE reviews_author (   id_author int(11) NOT NULL auto_increment,   fname_author varchar(30) NOT NULL,   lname_author varchar(50) NOT NULL,     PRIMARY KEY (id_author), )'; $result = mysql_query($sql) or print ("Can't create the table 'reviews_author' in the database.<br />" . $sql . "<br />" . mysql_error()); if ($result != false) { echo('Article database created successfully!'); } $sql = 'CREATE TABLE reviews_date (   id_date int(11) NOT NULL auto_increment,   date_date timestamp(8) NOT NULL,     PRIMARY KEY (id_date), )'; $result = mysql_query($sql) or print ("Can't create the table 'reviews_date' in the database.<br />" . $sql . "<br />" . mysql_error()); if ($result != false) { echo('Article database created successfully!'); } $sql = 'CREATE TABLE reviews_category (   id_category int(11) NOT NULL auto_increment,   cat_category varchar(40) NOT NULL,     PRIMARY KEY (id_category), )'; $result = mysql_query($sql) or print ("Can't create the table 'reviews_category' in the database.<br />" . $sql . "<br />" . mysql_error()); if ($result != false) { echo('Article database created successfully!'); } $sql = 'CREATE TABLE reviews_post (   id_post int(11) NOT NULL auto_increment,   idpost_date int(11),   idpost_author int(11),   title_post varchar(100) NOT NULL,   intro_post varchar(200) NOT NULL,   text_post text NOT NULL,   PRIMARY KEY (id_post),   FOREIGN KEY idpost_date REFERENCES reviews_date(id_date),   FOREIGN KEY idpost_author REFERENCES reviews_author(id_author) )'; $result = mysql_query($sql) or print ("Can't create the table 'reviews_post' in the database.<br />" . $sql . "<br />" . mysql_error()); if ($result != false) { echo('Article database created successfully!'); } $sql = 'CREATE TABLE reviews_post_category (   id_post int(11),   id_category int(11),   PRIMARY KEY (id_post, id_category),   FOREIGN KEY id_post REFERENCES reviews_post(id_post),   FOREIGN KEY id_category REFERENCES reviews_category(id_category), )'; $result = mysql_query($sql) or print ("Can't create the table 'reviews_post_category' in the database.<br />" . $sql . "<br />" . mysql_error()); if ($result != false) { echo('Article database created successfully!'); } $sql = 'CREATE TABLE reviews_link (   id_link int(11) NOT NULL auto_increment,   url_link varchar(150) NOT NULL,     PRIMARY KEY (id_link), )'; $result = mysql_query($sql) or print ("Can't create the table 'reviews_link' in the database.<br />" . $sql . "<br />" . mysql_error()); if ($result != false) { echo('Article database created successfully!'); } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.