ljmyers Posted January 8, 2009 Share Posted January 8, 2009 I'm Lost - I have a php recipe script that I am wanting to pull the info (recipe name, ingredients, directions, etc) from the individual recipe page via a link on this page to a new page that will show the recipe in a different manner or style. I did this one along time ago using a combo of php and java script but for some reason, I've worked on it all day and I cannot figure it out. I have included the code below from the file that allows the script to show each specific recipe and this being the page/file I want to pull the recipe details from . . . <?php session_start(); $string = "ABCEFGHJKMNPRSTWYZ23456789"; // salt to select chars from srand((double)microtime()*1000000); // start the random generator $thecode=""; // set the inital variable for ($i=0;$i<5;$i++){ // loop and create password $thecode = $thecode . substr ($string, rand() % strlen($string), 1); } $_SESSION["verification_key"] = $thecode; include("thumbnail.php"); include("include.php"); ///Get recipe details $id = $_REQUEST["id"]; $res_recipe = mysql_query("select a.*, b.first_name, b.last_name, date_format(post_date, '".Get_Date_Format($date_format)."') as formatted_date from ".TABLE_PREFIX."recipes a left join ".TABLE_PREFIX."users b on a.user_id = b.id where a.id = '$id'"); if($row_recipe = mysql_fetch_array($res_recipe)) { $vews = $row_recipe["views"]; $new_views = $vews+1; $res_view = mysql_query("update ".TABLE_PREFIX."recipes set views = '$new_views' where id = '$id'"); if($row_recipe["picture"]!="") if(file_exists("admin/uploads/".$row_recipe["picture"])){ { if (makethumb($row_recipe["picture"], "admin/uploads", "150" , "L_", "admin/uploads") ){ $pathtopic2 = $NewThumbFileName; } else{ $pathtopic2 ="admin/uploads/".$row_recipe["picture"]; } } } else{ $pathtopic2 = ""; } } $html_title = $row_recipe["html_title"]; if ($html_title ==""){ $html_title = $row_recipe["name"]; } $html_keywords = $row_recipe["html_keywords"]; if ($html_keywords ==""){ $html_keywords = $row_recipe["name"]; } $html_description = $row_recipe["html_description"]; if ($html_description ==""){ $html_description = $row_recipe["name"]; } printheader(1,$html_title,$html_keywords,$html_description); $res_df = mysql_query("select * from ".TABLE_PREFIX."settings"); if($row_df = mysql_fetch_array($res_df)) { ///Date Format $date_format = $row_df["date_format"]; ///User Comments - fSol add $user_comments = $row_df["user_comments"]; ///Guest Comments - fSol add $guest_comments = $row_df["guest_comments"]; } ?> <script language="JavaScript" src="genfns.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> // <![CDATA[ function Validation(input) { var requiredFields = new Array("post_name","post_email","comment","key"); var fieldNames = new Array("Name","Email","Comment","Varification Code"); var fieldCheck = true; var fieldsNeeded = "\nA value must be entered in the following field(s):\n\n\t"; for(var fieldNum=0; fieldNum < requiredFields.length; fieldNum++) { if ((input.elements[requiredFields[fieldNum]].value == "") || (input.elements[requiredFields[fieldNum]].value == " ")) { fieldsNeeded += fieldNames[fieldNum] + "\n\t"; fieldCheck = false; } } if (fieldCheck == true){ if (document.frmitem.post_email.value!=""){ if (!emailCheck(document.frmitem.post_email.value)) return false else return true } else{ return true; } } else { alert(fieldsNeeded); return false; } } function ViewPrint(id) { newWindow = window.open('/print.php?id='+id, 'Print', 'width=600,height=500, scrollbars=yes'); newWindow.focus(); } function ViewPhoto(id,imagewidth,imageheight) { newWindow = window.open('/view_photo.php?id='+id, 'Details', 'width='+imagewidth+',height='+imageheight+', scrollbars=yes, resizable =1'); newWindow.focus(); } // ]]> </script> <table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="text"> <tr> <td> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="text" style="margin-bottom:0px;"> <tr> <td align="center" style="border: 1px solid #d6d6d6;padding:3px;color:#d6d6d6;"><?php if(isset($_COOKIE["ses_code"])){ ///If the user logged in if($_COOKIE["ses_code"] == md5($_COOKIE["ses_username"].$_COOKIE["ses_id"])) { ///If not added to favourites before $res_fav = mysql_query("select * from ".TABLE_PREFIX."favourites where recipe_id ='$id' and user_id ='".$_COOKIE["ses_id"]."'"); if(mysql_num_rows($res_fav)==0) { ?> <a href="<?php echo $url_script;?>add_to_fav.php?recipe_id=<?php echo $id;?>">Add To CookBook</a> | <?php } } } ?> <a href="http://www.myurl.com/file.php" title="print recipe card">Print Recipe Card</a> | <a href="http://www.myurl.com/file.html" title="print keepsake cookbook">Print CookBook</a> | <a href="http://www.myurl.com/page/file.html" title="print canning label">Print Canning Label</a> | <a href="javascript: ViewPrint('<?php echo $id;?>');" title="print recipe">Basic Print</a> | <a href="<?php echo $url_script;?>sendtofriend.php?id=<?php echo $id;?>" title="email recipe">Email Recipe</a></td> </tr> </table> <h1>[color=red]<?php echo $row_recipe["name"];?>[/color]</h1> </td> </tr> <tr> <td style=" padding-left:0px"> <?php ///If picture uploaded if($row_recipe["picture"]!="") { if(file_exists("admin/uploads/".$row_recipe["picture"])){ $size = getimagesize("admin/uploads/".$row_recipe["picture"]); $imgwidth = $size[0]; $imgheight = $size[1]; if ($imgwidth >600) { $newimagewidth = 600; } else{ $newimagewidth = $imgwidth+40; } if ($imgheight >500) { $newimgheight = 500; } else{ $newimgheight = $imgheight+80; } ///Option to enlarge the picture ?> <a href="javascript: ViewPhoto('<?php echo $id;?>','<?php echo $newimagewidth;?>','<?php echo $newimgheight;?>');"> <img src="<?php echo $url_script;?><?php echo $pathtopic2;?>" class="imageborder" alt="<?php echo $row_recipe["name"];?>" width="150" border="0" style="float:left;" /> </a> <?php if ($row_recipe["first_name"] == ""){ ?> Submitted by: Lana on <?php echo $row_recipe["formatted_date"];?><br /> <?php } else{?> Submitted by: [color=red]<?php echo $row_recipe["first_name"]." ".$row_recipe["last_name"];?>[/color] on <?php echo $row_recipe["formatted_date"];?><br /> <?php }?> <?php } } ?> <?php echo $row_recipe["views"];?> views<br /> <?php echo $row_recipe["mark"];?> avg rating<br /> <?php echo $row_recipe["votes"];?> votes <?php ///If not rated before $res_fav = mysql_query("select * from ".TABLE_PREFIX."rates where recipe_id ='$id' and user_ip = '".$_SERVER['REMOTE_ADDR']."'"); if(mysql_num_rows($res_fav)==0) { ?> <table><tr><td style="font-weight:500;padding:0px;" align="right">Rate This Recipe:</td><td align="left"> <div> <ul class='star-rating'> <li class='current-rating' style='width: <?php echo number_format(($row_recipe["mark"]*20),0);?>%;'></li> <li><a href='/saverate.php?recipe_id=<?php echo $id ?>&rate=1' title='1 star out of 5' class='one-star'>1</a></li> <li><a href='/saverate.php?recipe_id=<?php echo $id ?>&rate=2' title='2 stars out of 5' class='two-stars'>2</a></li> <li><a href='/saverate.php?recipe_id=<?php echo $id ?>&rate=3' title='3 stars out of 5' class='three-stars'>3</a></li> <li><a href='/saverate.php?recipe_id=<?php echo $id ?>&rate=4' title='4 stars out of 5' class='four-stars'>4</a></li> <li><a href='/saverate.php?recipe_id=<?php echo $id ?>&rate=5' title='5 stars out of 5' class='five-stars'>5</a></li> </ul> </div> </td></tr></table> </td> </tr><tr><td> <?php }else{ ?> <table><tr><td style="font-weight:500;padding:0px;" align="right">Already Rated</td><td align="left"> <div> <ul class='star-rating'> <li class='current-rating' style='width: <?php echo number_format(($row_recipe["mark"]*20),0);?>%;'></li> <li><a onClick="javascript: void(0)" title='1 star out of 5' class='one-star'>1</a></li> <li><a onClick="javascript: void(0)" title='2 stars out of 5' class='two-stars'>2</a></li> <li><a onClick="javascript: void(0)" title='3 stars out of 5' class='three-stars'>3</a></li> <li><a onClick="javascript: void(0)" title='4 stars out of 5' class='four-stars'>4</a></li> <li><a onClick="javascript: void(0)" title='5 stars out of 5' class='five-stars'>5</a></li> </ul> </div></td></tr></table> </td> </tr><tr><td> <?php } ?> <table style="width:100%" class="text"><tr> <td> <br />[color=red]<?php echo nl2br($row_recipe["description"]);?>[/color]<br /><br /> <?php if($row_recipe["ingredients"]!=""){?> <font style="font-weight:600;color:#75A54B;font-size:12px;line-height:20px;">Ingredients</font><br /> [color=red]<?php echo nl2br($row_recipe["ingredients"]);?>[/color] <?php } if($row_recipe["directions"]!=""){?> <br /><br /><font style="font-weight:600;color:#75A54B;font-size:12px;">Directions</font>: [color=red]<?php echo nl2br($row_recipe["directions"]);?>[/color] <?php } if($row_recipe["nutritional"]!=""){?> <br /><br /><font style="font-weight:600;color:#75A54B;font-size:12px;line-height:18px;">Weight Watchers Info</font>:<br /> <?php echo nl2br($row_recipe["nutritional"]);?> <?php } if($row_recipe["comments"]!=""){?> <br /><br /><font style="font-weight:600;color:#75A54B;font-size:12px;line-height:18px;">Comments</font>: <?php echo nl2br($row_recipe["comments"]); } if($row_recipe["course"]!=""){?> <br /><br /><font style="font-weight:600;color:#75A54B;font-size:12px;line-height:18px;">Course</font>: <?php echo nl2br($row_recipe["course"]); } if($row_recipe["servings"]!=""){?> <br /><br /><font style="font-weight:600;color:#75A54B;font-size:12px;line-height:18px;">Servings</font>: <?php echo nl2br($row_recipe["servings"]); } if($row_recipe["calories"]!=""){?> <br /><br /><font style="font-weight:600;color:#75A54B;font-size:12px;line-height:18px;">Calories</font>: <?php echo nl2br($row_recipe["calories"]); } if($row_recipe["preparetime"]!=""){?> <br /><br /><font style="font-weight:600;color:#75A54B;font-size:12px;line-height:18px;">Time to Prepare</font>: <?php echo nl2br($row_recipe["preparetime"]); } if($row_recipe["difficulty"]!=""){?> <br /><br /><font style="font-weight:600;color:#75A54B;font-size:12px;line-height:18px;">Difficulty</font>: <?php echo nl2br($row_recipe["difficulty"]); } ?> </td> </tr></table> <table style="width:100%"><tr> <td> </td> </tr> <tr> <td style="font-weight:700;color:#75A54B;font-size:13px;border-top: #CCCCCC solid 1px;padding-top:10px;">Comments</td> </tr> <tr> <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="3" class="text"> <tr><td align="left"><?php echo nl2br($row_com["comment"]);?> </td></tr> <?php ///Get the comments on this recipe $res_com = mysql_query("select *, date_format(post_date, '".Get_Date_Format($date_format)."') as formatted_date from ".TABLE_PREFIX."comments where recipe_id = '$id'"); while($row_com = mysql_fetch_array($res_com)) { ?> <tr> <td align="left"><?php echo nl2br($row_com["comment"]);?> </td> </tr> <tr> <td align="right"> <?php ///checking wheather the comment was posted by registered user or not if($row_com["user_id"]!=0){?> <a href="<?php echo $url_script;?>view_profile.php?id=<?php echo $row_com["user_id"];?>"><strong><?php echo $row_com["post_name"];?></strong></a> <?php }else {?> <strong><?php echo $row_com["post_name"];?></strong><?php }?> on <?php echo $row_com["formatted_date"];?></td> </tr> <tr> <td style="border-bottom: #CCCCCC solid 1px;text-align:center;padding-bottom:5px;"></td> </tr> <?php } ?> </table></td> </tr></table> <table style="width:100%"> <tr> <td> </td> </tr> <tr> <td style="font-weight:600;color:#75A54B;font-size:12px;">Post Comment</td> </tr> <?php // If Users can't post comments if($user_comments == 0){ ?> <tr> <td>Users are not allowed to post comments</td> </tr> <?php // If Guests can't post comments and current user is guest - fSol }else if($guest_comments == 0 && $_COOKIE["ses_code"] != md5($_COOKIE["ses_username"].$_COOKIE["ses_id"])){ ?> <tr> <td>Guests are not allowed to post comments</td> </tr> <?php // else show the form - fSol }else{ ?> <tr> <td style="border: #CCCCCC solid 1px"> <form action="<?php echo $url_script;?>savecomment.php" method="post" name="frmitem" id="frmitem" onsubmit="return Validation(this)" > <table width="90%" border="0" align="center" cellpadding="0" cellspacing="3" class="text"> <?php $temp_user ="no"; $post_name = ""; $post_email = ""; $user_id = 0; ///If the user logged in if(isset($_COOKIE["ses_code"])){ if($_COOKIE["ses_code"] == md5($_COOKIE["ses_username"].$_COOKIE["ses_id"])) { $temp_user ="yes"; $user_id = $_COOKIE["ses_id"]; $res_user = mysql_query("select * from ".TABLE_PREFIX."users where id = '".$_COOKIE["ses_id"]."'"); if($row_user = mysql_fetch_array($res_user)) { /// Storing logged user's email and password $post_name = $row_user["first_name"]; $post_email = $row_user["email"]; } } } ?> <tr> <td> </td> <td> </td> </tr> <tr> <td width="33%">Your name<span class="required">*</span></td> <td width="67%"><input name="post_name" class="textbox" type="text" size="40" value="<?php echo $post_name;?>" <?php if($temp_user =="yes") echo "readonly='1'";?> /></td> </tr> <tr> <td>Your email</td> <td><input name="post_email" class="textbox" type="text" size="40" value="<?php echo $post_email;?>" <?php if($temp_user =="yes") echo "readonly='1'";?>/></td> </tr> <tr> <td valign="top">Comment<span class="required">*</span></td> <td><textarea name="comment" cols="37" rows="8" class="textbox"></textarea></td> </tr> <tr> <td>Enter Verification code:<span class="required">*</span></td> <td><img src="<?php echo $url_script;?>picture.php" alt="Image verification" name="vimg" id="vimg" /> <br /> <input type="text" size="16" name="key" class="textbox" id="key" /></td> </tr> <tr> <td> </td> <td><input type="submit" class="button" name="Submit" value="Post" /> <input type="hidden" name="recipe_id" value="<?php echo $id;?>" /> <input type="hidden" name="user_id" value="<?php echo $user_id;?>" /></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> </td> </tr> <tr> <td > </td> </tr></table></td> </tr> <?php } // end - fSol ?> </table> <?php printfooter(); ?> And this is the page that I want the following details pulled to or to otherwise said - be able to view those details on this page . . . <!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>Personalize Print Recipe Card</title> <meta name="keywords" content="personalize, print, decorative, recipe, card, blue" /> <meta name="description" content="Personalize n print a decorative recipe card for this recipe here at RecipeRenaissance.com." /> </head> <body style="background-color:#FFFFFF;height:99%;margin:20px 0px 0px 50px;"> <h1 style="font-size:14px;color:black;margin-bottom:20px;">Personalize & print This Blue Recipe Card</h1> <table class="text" style="width:600px;height:400px;margin-right:auto;margin-left:auto;font-family:times,serif;color:#000000;font-size:12px;background-image: url(http://www.reciperenaissance.com/free_personalize_printable/img/blue.JPG);"> <tr> <td style="width:100%;"> <table style="width:100%;"> <tr> <td valign="middle" align="center" style="line-height:40px;padding-top:10px;text-align:center;font-size:27px;font-family:Amazone BT,times,serif;"> I am sorry for the delay but this is only a test recipe card while I am building the "personalized printable" pages. <b>[color=red]<?php echo $row_recipe["name"];?>[/color]</b> </td></tr> <tr><td align="center" valign="middle" style="text-align:center;padding-top:0px;font-size:23px;font-family:Amazone BT,times,serif;"> [color=red]<?php echo $_COOKIE["ses_username"]; ?> or first and last name[/color] </td></tr> <tr><td align="center" valign="middle" style="text-align:center;padding:10px 10px 0px 10px;font-size:12px;"> [color=red]<?php echo nl2br($row_recipe["comments"]);?>[/color] </td></tr> <tr> <td style="width:100%;min-height:115px;padding:0px 10px 0px 10px;"> [color=red]<?php if($row_recipe["ingredients"]!=""){?><strong>Ingredients</strong><br /><?php echo nl2br($row_recipe["ingredients"]);?> | <?php }?>[/color] </td></tr> <tr><td style="width:100%;min-height:115px;padding:0px 10px 0px 10px;"> [color=red]<?php if($row_recipe["directions"]!=""){?><strong>Directions:</strong> <?php echo nl2br($row_recipe["directions"]);?><br><br /><?php }?>[/color] </td></tr> </table> </td></tr> <tr><td align="right" valign="bottom" style="width:100%;height:12px;padding: 0px 3px 3px 0px;font-size:10px;color:#444444;font-style:italic;"> MyUrl.com </td> </tr> </table> </body> </html> Thanks up front for any suggestions, help or references. Lana Link to comment https://forums.phpfreaks.com/topic/140048-php-dummy/ Share on other sites More sharing options...
ljmyers Posted January 9, 2009 Author Share Posted January 9, 2009 I figured it out so not to worry. Thanks anyway. Link to comment https://forums.phpfreaks.com/topic/140048-php-dummy/#findComment-732976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.