PHP - Display A Preview
so I have this code.......
Code: [Select] <?php include 'config1.php'; include 'opendb.php'; // if no id is specified, list the available articles if(!isset($_GET['id'])) { $self = $_SERVER['PHP_SELF']; $query = "SELECT id, title FROM news ORDER BY id DESC"; $result = mysql_query($query) or die('Error : ' . mysql_error()); // create the article list while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($id, $title) = $row; $content .= "<p><a href=\"$self?id=$id\">$title</a></p>\r\n"; } $title = 'News'; } else { // get the article info from database $query = "SELECT title, content FROM news WHERE id=".$_GET['id']; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $title = $row['title']; $content = $row['content']; } include 'closedb.php'; ?> <?php $query = "INSERT INTO view_news (`topic_id`, `user_id`) VALUES ($id, $userid) ON DUPLICATE KEY UPDATE `user_id`=`userid`"; ?> <?php $query = "SELECT *.news, IF(`view)news.user_id`=$userid, 1, 0) as viewed FROM `news` LEFT JOIN `view_news` ON `topics.id` = `view_news.topic_id` AND `view_news.user_id` = $user_id"; while($row = mysql_fetch_assoc($result)) { //Create the style for the article link $style = ($row['viewed']==0) ? 'font-weight:bold;' : ''; echo "<a href=\"news.php?id={$row['id']}\" style=\"{$style}\">$row{['title']}</a><br />\n"; } ?> <!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"><!-- InstanceBegin template="/Templates/template2.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!-- InstanceBeginEditable name="doctitle" --> <title>News</title> <!-- InstanceEndEditable --> <style type="text/css"> #editregion { position:absolute; left:-2px; top:272px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } body { background-image: url(button/boyscout1.png); background-repeat: no-repeat; position: relative; } #menu { position:relative; left:160px; top:0px; width:931px; height:59px; z-index:19; } #menu #MenuBar1 li a { color: #000; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; width: 100px; } #status { position:relative; left:16px; top:180px; width:124px; height:44px; z-index:14; } </style> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> <!-- InstanceBeginEditable name="head" --> <style type="text/css"> </style> <style type="text/css"> a:link { color: #00F; } #editregion table tr td { text-align: left; } </style> <!-- InstanceEndEditable --> <!-- InstanceParam name="id" type="text" value="apDiv6" --> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #logout { position:relative; left:0px; top:0pxpx; width:134px; height:38px; z-index:20; font-weight: bold; font-size: 24px; } #logout a { color: #000; } #footer { position:absolute; left:98px; top:512px; width:239px; height:70px; z-index:21; clear: both; float: none; } #status { text-align: center; } #logout1 { position:absolute; left:1071px; top:191px; width:224px; height:61px; z-index:2; } #menu2 { position:absolute; left:-1px; top:172px; width:497px; height:92px; z-index:20; } </style> </head> <body> <div id="logout1"><div id="logout"><a href="logout.php">Logout</a></div></div> <div id="status"><?php echo "$accounttype"; ?> <br /><?php echo "$name"; ?> <p> </p> </div> <div id="editregion"><!-- InstanceBeginEditable name="EditRegion3" --><style type="text/css"> // ... some css here to make the page look nicer </style> <table width="600" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#336699"> <tr> <td bgcolor="#FFFFFF"> <h1 align="center"><?php echo $title; ?></h1> <?php echo $content; // when displaying an article show a link // to see the article list if(isset($_GET['id'])) { ?> <p> </p> <p align="center"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Back to News</a></p> <?php } ?> </td> and basically what I want to do is pull content from a database that I have so that like the first 100 words will display under the link before it is clicked.........is there a way to do this? Similar TutorialsIs there any way to generate a small image of the 1st page of a pdf document without using a 3rd party like imagemagic. The site is hosted a register.com so I am thinking I am going to be limited to the basic php functions. Hi, im trying to figure out how to have a form preview something next to the form depending on what options have been selected on a form. So let me explain better what i mean. I want to create a form which is for customers to create a custom product (in this case a nameplate). The options could be something like; letters (what word they want) font type: [few different font names here] font size: [small, medium, large] color: ... So if the customer typed in 'name' in the letters field then it would be displayed in the preview box If the customer then selected a font type, the change would then be reflected in the preview box.. and so on. I hope you understand what i trying to explain. I can just about handle creating the form but i don't know how to have it display what options have been chosen. If this is too much effort would it just be easier to submit this form and then display the data? or is it not too complicated to have it display on the same form before you submit it? I would prefer it displayed on the same page Thanks for any help. <?php $files=glob('apk/*'); foreach( $files as $file) { echo '<img scr="'.$file.'">'.basename($file).'</img><br/>'; } ?> I have just completed a modest way for Users to post Comments on Articles my website. However, the thought occurred to me today, that I haven't given Users the ability to Preview or Edit their comments after submittal. What is the best way to store info on a Comments Form so you can re-display it for Preview/Editing?? (I'm not really sure how the workflow would work for this?!) Do I capture the Comments Form Data and store it in a Session? Or in my Database? Or do something else? Security is always a concern of mine too!! Thanks, Debbie I added the ability for Users to "preview" their Comments before submitting them. I just realized that when they click "Preview" that their Comments appear above the Comments form box - similar to how PHPFreaks works - but that the Comments form box loses it's data since the page reload causes this to lose things... <li> <label for="comments">Comments:</label> <textarea id="comments" name="comments" cols="50" rows="15"><?php if (isset($comments)){echo nl2br(htmlentities($comments, ENT_QUOTES));} ?></textarea> <?php if (!empty($errors['comments'])){ echo '<span class="error">' . $errors['comments'] . '</span>'; } ?> </li> What is the easiest way to maintain form persistence? (I really would like to avoid having to store things in my database during the preview.) How does PHPFreaks do things? I was going to use a SESSION, but since this is a Comments field that can take up to 65,535 characters, that probably won't work?! Any ideas? Debbie my issue is to show preview of a form. the form will have a fck editor . this form is used to update a table. i need to show a preview button on this page and when we click on it should show the preview of the content. i am attaching my code. my problem is this is a update page fck value is taken from Dn "$desc" . when do some changes on editor then i click on preview button should show the changes, here showing only the $dec value from DB not the value i change. <?php session_start(); $uname=$_SESSION['usname']; include("dbconnect.php"); $admin_qry="select * from st_admin where admin_username='$uname'"; $res=mysql_query($admin_qry); $admin_res=mysql_fetch_array($res); $level=$admin_res['level']; include("status.php"); ?> <script language="javascript" src="ajax/ajax.js"></script><?php $pos=$_REQUEST['pos2']; $getqry="select * from st_aboutus where categorys='$pos'"; $resr=mysql_query($getqry); $row=mysql_fetch_array($resr); $cat=$row['categorys']; $img=$row['st_img']; //$description=$row['st_content']; $desc=stripslashes($row['st_content']); $file_name=$row['file_name']; $id=$row['st_id']; ?> <script language="javascript"> function popUpPreview() { // Display a new browser for the user var w = screen.availWidth / 2 - 450; var h = screen.availHeight / 2 - 320; var win = window.open('aboutus-prewiew.php', 'payPopupMain', 'width=900,height=650,left='+w+',top='+h+',scrollbars=1'); } </script> <link href="../css/style.css" rel="stylesheet" type="text/css" /> <form name="sform" id="sform" action="update_aboutus.php" method="post"> <table width="679" height="323" border="0" align="center" cellpadding="0" cellspacing="0" > <tr> <td colspan="5" height="40" align="left" class="page_head" valign="top"> </td> </tr> <tr> <td align="left" class="textfont"> </td> <td align="left" class="textfont"> </td> <td height="40" align="left"> </td> <td height="40" align="left" class="normaltext"><?php if($level=="dataentry" ){} else {echo " Status " ; } ?></td> <td align="left"><span style="padding-left:10px;"> <?php if($level=="dataentry" ){} else { showStatus('st_aboutus','st_id','status',$id) ; } ?> </span></td> </tr> <tr> <td width="170" align="left" class="textfont"> </td> <td width="8" align="left" class="textfont"> </td> <td height="40" colspan="3" align="left"><?php echo $message=$_GET[msg]; ?></td> </tr> <tr> <td height="19" class="listitem" align="right"> </td> <td class="listitem" align="left"> </td> <td height="19" align="left" class="listitem1">Image Size 274 X 420</td> <td colspan="2" align="left"></td> </tr> <tr> <td height="71" class="listitem" align="right">Add Image</td> <td class="listitem" align="left"> </td> <td width="236" height="71" align="left"><input name="logo" type = "text" id="logo" value="<?php echo $img; ?>" size="20" readonly="readonly" class="txtbox" /> <img src="../images/attach.gif" onClick="attachment('logo','logoimage')" class="imagebutton12" /> <img src="../images/remove.gif" onClick="removeattachment('logo','logoimage')" class="imagebutton12" /></td> <td width="265" colspan="2" align="left"><img src="<?php if($img) {echo "aboutus/".$img; } else { echo "../images/photo.gif "; } ?>" width="67" height="62" name="logoimage8" id="logoimage" /> <input type="hidden" name="image1_hiid" id="image1_hiid" value="<?php echo $img; ?>" /></td> </tr> <tr> <td colspan="5" align="left" class="optimumSize" valign="bottom"><!--Optimum size of image is 120 X 105 --></td> </tr> <tr> <td height="10" colspan="2" class="textfont"> </td> <td height="10" colspan="3"><?php include("../FCKeditor/fckeditor.php"); $oFCKeditor = new FCKeditor('desc') ; $oFCKeditor->BasePath = '../FCKeditor/'; /* $oFCKeditor->Value =stripslashes(substr($intro,0,500));*/ $oFCKeditor->Value = $desc; // here we can give size of editor as $oFCKeditor->Width = '600' ; $oFCKeditor->Height = '250' ; $oFCKeditor->Create() ; ?></td> </tr> <tr> <td height="27" align="right" class="listitem"> </td> <td height="27" class="textfont"> </td> <td height="27" align="left" valign="bottom"><span class="listitem1"><?php /*?><?php if($pos!="management" ){} else {echo " Only Upload ".pdf" file";} ?><?php */?></span></td> <td height="27" colspan="2" align="left"> </td> </tr> <?php /*?><?php if($pos!="management" ){} else {echo " <tr> <td height='68' align='right' class='listitem'>Update pdf</td> <td height='68' class='textfont'> </td> <td height='68' align='left'> <input name='logo1' type = 'text' id='logo1' value='$file_name' size='20' readonly='readonly' class='txtbox' /> <img src='../images/attach.gif' onclick=\"attachment('logo1','logoimage1')\" class='imagebutton12' /> <img src='../images/remove.gif' onclick=\"removeattachment('logo1','logoimage1')\" class='imagebutton12' /></td> <td height='68' align='left'><img src=\"aboutus/$file_name\" width='67' height='62' name='logoimage1' id='logoimage1' /></td> </tr> ";} ?><?php */?> <tr> <td height="36" colspan="2"><input type="hidden" name="des" id="des" value="<?php echo $img; ?>" /></td> <td align="left"><input name="preview" type="button" onclick="return popUpPreview();" value="Preview"/></td> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><input type="hidden" name="id" value="<?php echo $id; ?>"><input type="hidden" name="pos" value="<?php echo $pos; ?>"> <input type="hidden" name="image1_hiid1" id="image1_hiid1" value="<?php echo $file_name; ?>" /></td> <td align="left"> <input type="image" name="image" value="Submit" src="../images/submit.gif" alt="Login Details" title="Submit" onclick="return fieldcheck(this.form);"></td> <td colspan="2"> </td> </tr> <tr><td colspan="5" height="10"></td></tr> </table> </form> aboutus-prewiew.php <script type="text/javascript"> document.write(opener.document.sform.logo.value); document.write(opener.document.sform.desc.value); // this value only showing from the database ,i need to get the value to show preview </script> Hi Everyone, I will have a web application that users fill out and submit. I also have the same form in PDF format. I would like users to be able to click a print preview button, then open up FoxIt or Adobe and display the PDF, with their answers mapped to the correct location. I have no code, just looking for a direction and didn't know what to search for. Thanks. I’m trying to write a post-panel where the user can see the preview of his post to the right of the text area he’s writing into. I tried the following into a file called writepost.php : <?php $text=(isset($_GET['message']))?$_GET['message']:''; $formatted_text=nl2br(stripslashes(htmlspecialchars($text))); echo '<form method="post" action="proceedtopost.php?>'. '<table>'. '<td style width="50%"><tr>'. '<fieldset> Write your post here : <br> <textarea cols="50" rows="12" '. 'id="message" name="message">'.$text.'</textarea>'. '</fieldset> <p> '. '<input type="submit" name="submit" formaction="writepost.php" value="Preview" /> '. '<input type="submit" name="submit" value="Sent" /> '. '</p>'. '</td>'. '<td>'. '<fieldset> Your post will appear as follows :<br><p> '. $formatted_text. '</fieldset>'. '</td></tr>'. '</table>'. '</form>';There are several things wrong with this code : 1) When the user hits the "Preview" button, I expect writepost.php to be reloaded (this is what happens), and the current content of the textarea to be stored in $_GET['message'] (this is not what happens). 2) Why does my browser output the preview part under the text area (or in other words outputs the HTML table as a single column of two cells), when I insist in my HTML code for the table to be displayed as a single row ? Back again!! I have been trying to think of a way to do this but its starting to make my brain itch a bit too much now!!! I have the code below to display my query. Basicly its to disply 3 images and when 'x=a multiple of 3' it ends the row and starts another. The only problem is, that the first result will not be displayed as x has to begin at 1. if x begins at 0, it will display the first result and begin a new line. Code: [Select] echo "<center><table border='0' cell padding='3'><tr>"; $x = 1; while ($x < $num) { $id=mysql_result($result,$x,"id"); $caption=mysql_result($result,$x,"cap"); $address=mysql_result($result,$x,"address"); $date=mysql_result($result,$x,"date"); $album=mysql_result($result,$x,"album"); $member=mysql_result($result,$x,"member"); echo "<td><center><img src='/images/uploads/main/thumb_".$address."'><br>$caption</center></td>"; echo ($x % 3 == 0)? "</tr><tr>" : ""; $x++; } echo "</tr></table>"; Can anyone point me in the right direction?? Thanks Eric So I have this script. I connected the database and verified a working connection to the base, password correct. As I save the script on my server it saved the changes and I view the file online. The resulting page is blank. Really need help completing this code as it's essential to my sites organization, have a look below and help me if possible.
<?php I want to grab a list of all the school programs I have in a database (math english biology chemistry ect ect) and dispaly them in a order so that they go alphabetically downward for 12 rows and then go across so it would look like soo: Academic Advisory Class Schedules Academic Assistance Counselling Center Academic Calendars Course Descriptions and Catalogue Academics Office Department Directory Administration Departments & Programs Adult Learners Fellowships Alumnimni Chapters Finals Schedules Alumni Events Athletics Campus Life At a Glance Campus Recreation Campus Safety & Security I know to get he I am just unsure what to do in the while array to make it look how I want Code: [Select] <?php $sql = "SELECT name,id FROM table_name ORDER BY name ASC"; $res =mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($res)){ //now what??? } ?> Hi everyone, im not sure if this topic belongs in CSS so please move if it is but... I have a style sheet with some boxes i want my SQL results to go into, i want to know how to echo the results into the boxes. heres the html: Code: [Select] <!DOCTYPE html> <head> <title>Compaines | Removalspace.com</title> <style type="text/css"> <!-- body { background-image: url(styles/downloaded%20styles/todo/todo/images/bg.png); } --> </style> <link href="styles/downloaded styles/todo/todo/css/style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/style9.css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/demo.css" /> <link href='http://fonts.googleapis.com/css?family=Terminal+Dosis' rel='stylesheet' type='text/css' /> <style type="text/css"> <!-- .Stile1 {color: #333333} --> </style> </head> <body> <!--start container --> <div id="container"> <header> <nav> <div id="logo"><a href="#"><img src="images/removalspace1.png" alt="Logo here" width="463" height="135" /></a> </div> <div id="search-top"> <form method="post" action="search.php"> <input type="text" onFocus="if(this.value=='Search')this.value='';" onBlur="if(this.value=='')this.value='Search';" value="Search" id="search-field"/> <input type="submit" value="" id="search-btn"/> </form> </div> <div id="nav_social"><a href="http://www.facebook.com/pages/Removalspace/181434181939226"><img src="styles/downloaded styles/todo/todo/images/facebook_32.png" alt="Become a fan" width="32" height="32" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/twitter_32.png" alt="Follows on Twitter" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/linkedin_32.png" alt="Linked in" /></a><a href="contact.php"><img src="styles/downloaded styles/todo/todo/images/email_32.png" alt="Contact" width="32" height="32" /></a> </div> </nav> </header> <div class="content"> <ul class="ca-menu"> <li> <a href="removals.php"> <span class="ca-icon">A</span> <div class="ca-content"> <h2 class="ca-main">Bringing removals home</h2> <h3 class="ca-sub">All in one place</h3> </div> </a> </li> <li> <a href="storage.php"> <span class="ca-icon">I</span> <div class="ca-content"> <h2 class="ca-main">Find the storage space</h2> <h3 class="ca-sub">Near You</h3> </div> </a> </li> <li> <a href="advertise_page.php"> <span class="ca-icon">C</span> <div class="ca-content"> <h2 class="ca-main">Advertise</h2> <h3 class="ca-sub">Your Business</h3> </div> </a> </li> <li> <a href="contact.php"> <span class="ca-icon">S</span> <div class="ca-content"> <h2 class="ca-main">Sophisticated Team</h2> <h3 class="ca-sub">Professionals in action</h3> </div> </a> </li> </ul> <!--star main --> <main> <div class="abox"> <figure> <fcapion> <h1>Company... </h1> </fcaption><a href="index-delete.php"></a><a href="#"><img src="images/images-8.jpeg" alt="I love graphic" width="200" height="200" /></a></figure> </div> <div class="abox"> <figure> <fcapion> <h1>Address... </h1> </fcaption> <a href="#"><img src="images/storagespace.jpg" alt="I love graphic" width="200" height="200" /></a> </figure> </div> <div class="abox"> <figure> <fcapion> <h1>Phone...</h1> </fcaption><a href="#"></a><a href="#"><img src="images/transport.jpg" alt="I love graphic" width="200" height="200" /></a></figure> </div> </main> <!--end main --> <!--start middle --> <middle> <div class="enter"> <P >Sign up to removalspace.com to advertise your business, choose from easy payment packages or add a FREE listing. Click the link to get started<br></P> <div class="imgteaser"> <a href="login-or-register.php"><img src="images/free listing2.jpg" alt="Todo el Todo" width="413" height="220" /><span class="desc"> <strong>Sign Up For Free!</strong> Start by making a FREE listing today.</span></a></div> </div> <div class="section_slogan"><img src="styles/downloaded styles/todo/todo/images/quote-right.png" alt="images" /><span class="cursive"> Nobody likes moving but finding the right people is easy at least with Removalspace.com</span><img src="styles/downloaded styles/todo/todo/images/quote-left.png" alt="images" /></div> <div class="middle_box"><h1><img src="styles/downloaded styles/todo/todo/images/fav.png" width="16" height="16" /> <a href="#">Resources</a></h1> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Search thousands of removal companies </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Search for a storage facility near you </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Contact Us </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> About removalspace. </ol> </div> <div class="middle_box"><h1><img src="styles/downloaded styles/todo/todo/images/fav.png" width="16" height="16" /> <a href="#">Blogs</a></h1> <p><img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Recent Post</p> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Post your comments </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Read Reviews </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Recent removalspace things. </ol> </div> <div class="middle_box"> <h1><img src="styles/downloaded styles/todo/todo/images/fav.png" width="16" height="16" /> <a href="#">Other </a></h1> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Advertisment Page <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Affiliate Links </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Our Packages. </ol></div> </middle> </div> <!--end middle --> <!--start footer --> <footer> <div id="footer"> <div id="footerleft"> <h2>removalspace</h2> <ul> <li><a href="http://www.imediacreatives.it">Contact</a></li> <li><a href="styles/downloaded styles/todo/todo/...">About Us</a></li> <li><a href="styles/downloaded styles/todo/todo/...">Other</a></li> </ul> </div> <div id="footermiddle"> <h2>User Comments</h2> <ul> <li><a href="styles/downloaded styles/todo/todo/...">Read Reviews</a></li> <li><a href="http://www.imediacreatives.it">Leave A Comment</a></li> <li><a href="styles/downloaded styles/todo/todo/...">Read Blogs</a></li> </ul> </div> <div id="footerright"> <h2>our mission</h2> <ul> <li><a href="">Who Are We?</a></li> <li><a href="">What We Do</a></li> <li><a href="">Our Mission</a></li> </ul> </div> <details> <summary> <p> Copyright © removalspace.com -2012.</p></summary><p></p> </details> </div> </footer> <!--end footer --> </div> <!--end container --> <!-- Free template distributed by http://freehtml5templates.com --> </body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> </html> heres the php code: Code: [Select] <?PHP include ('db.php'); $query = "SELECT * FROM companies ORDER BY approved DESC, company_name ASC"; $result = mysql_query($query); ?> <table border="0" cellpadding="1" cellspacing="2" bordercolor="#0066FF" background="images/table-images/back.png"> <tr> <th background="images/table-images/pattern.png">Company Name</th> <th background="images/table-images/pattern-head.png">Contact Name:</th> <th background="images/table-images/pattern.png">Contact Number:</th> <th background="images/table-images/pattern-head.png">Contact Email:</th> <th background="images/table-images/pattern.png">Address 1:</th> <th background="images/table-images/pattern-head.png">Address 2:</th> <th background="images/table-images/pattern.png">Area:</th> <th background="images/table-images/pattern-head.png">Postcode:</th> <th> - </th> <th> - </th> <th> - </th> <tr> <?php while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; SWITCH ($approved) { case 0: break; case 1: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td></td> <td></td> <td></td> </tr> <?PHP break; case 2: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['basicpackage_description']; ?></td> <td>-</td> <td>-</td> </tr> <?PHP break; case 3: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['basicpackage_description']; ?></td> <td><?PHP echo $row['premiumuser_description']; ?></td> <td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td> </tr> <?PHP break; } } echo "</table>"; ?> That is currently set to echo out a table but i only want "company" "address" "phone" to make things easier. Company name = box1 street1,street2, location, postcode = box2 (for address) phone = box3 I hope theres enough information for any help, thank you in advance! Hello. I am not entirely certain if this is even possible, but I don't see why it wouldn't. The document that I have is: Code: [Select] <?php include('../connection.php'); $query="SELECT * FROM projects"; $result=mysql_query($query); echo "<table border='1' cellpadding='10'>"; while($row = mysql_fetch_array( $result )) { echo "<tr>"; echo "<td>$row[id]</td>"; echo "<td>$row[name]</td>"; echo "<td>$row[text]</td>"; echo "<td><img src='../uploads/$row[image]'/></td>"; echo "<td><a href='editprojects.php?id=$row[id]'>Edit</a></td>"; echo "<td><a href='deleteprojects.php?id=$row[id]'>Delete</a></td>"; echo "</tr>"; } echo "</table>"; mysql_free_result($result); mysql_close($connection); ?> Basically, the only important line from that file is: Code: [Select] echo "<td><img src='../uploads/$row[image]'/></td>"; What I am doing is uploading images and other files to a PHP database. [image] = carries all the uploaded files. That single line shows every uploaded image in a row. But it doesn't show the SWF because obviously 'img src' isn't for swf's. Is it possible to add another code to THAT LINE to show the swf's? that single bit needs to be able to read images and swf's, Please help if you can. I have written a bra calculator, when the user enters their measurements their bra size is displayed however as the code I have used to do this came from a help tutorial I do not understand how it was constructed as I am quite a newb. The form works perfectly when returning data however if there is no size for a particular measurement it just displays nothing. I would like it to display N/A I have tried adding various if elses but without success. Any help is much appreciated Code: [Select] <FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD=get> <input type="text" name="band" value="<?php echo $_GET['band']; ?>" /> <input type="text" name="bust" value="<?php echo $_GET['bust']; ?>" /> <INPUT TYPE=submit VALUE="Calculate"> </FORM> <?php $band = $_GET['band']; $bust = $_GET['bust']; $query = sprintf("SELECT size FROM bra_calculator WHERE band='%s' AND bust='%s'", mysql_real_escape_string($band), mysql_real_escape_string($bust)); $result = mysql_query($query); if (!$result) { echo "no"; } else { while ($row = mysql_fetch_assoc($result)) { echo $row['size']; } } mysql_free_result($result); ?> Hey there, my problem is that I am trying to pull three images from a database and then displaying them with a large image above them. I want to then be able to click the smaller ones and then they become the larger one(kind of like on amazon). I am having 2 major problems with it at this point. the first is my while statement is only pulling 2 of the three images from the database, and secondly my image replacement javascript replaces with the smaller image. With the javascript it dosen't have to be done that way or in javascript so a link or suggestions on how to do that better would be great. So here's my code: <?php include('../../php/includes/openDbConn.php'); $sku = 'c-111111'; $getImages = "SELECT * FROM Images WHERE SKU = '".$sku."'"; $resultGetImages = mysql_query($getImages); $records = mysql_fetch_assoc($resultGetImages); ?> <img src="../../<?php echo $records['Path'] ?>" id="placeholder" alt="<?php echo $record['Description']; ?>" height="<?php echo $record['Width']; ?>" /> <div id="thumbImages"> <?php while($records = mysql_fetch_assoc($resultGetImages)){ echo "<a onclick=\"document.getElementById('placeholder').src='../../".$records['ThumbPath']."'\" target=\"_blank\"><img src=\"../../".$records['ThumbPath']."\" alt=\"".$records['Description']."\" height=\"".$records['ThumbWidth']."\" /></a>\n"; } ?> and a bit on the table with the images. It stores the sku and the Path of a thumbnail, regular and large sized image. All help is much appreciated. hi friends. to fetch results from the database i made a function and how i call the function on a page like $results = GetResults($someID); when i print_r the $results i get all the results, but now im confused on how do i print the rows individually? say i got Title row how will i only get the Title row from the $results VAR? This may be in here already and I'm sorry for not being able to find it but.. I just want to display some information that I get from the database in a HTML table only using 2 columns. Do I just set i=1 and run a if statement to see what column I am on? like Code: [Select] $i =0 While ($row = msyql_fetch_array($result)) { if ($i==0) { // start a new row echo "<tr>"; $i = $i++; }else{ //columns echo "<td>info</td>"; $i=$i++; } if ($i < 2) { //end the row reset $i echo "</tr>"; $i =0; } } Or something like that, am I heading in right direction? Thanks Stephen I have a PHP page that retrieves a PDF from a location on my server that isn't in the web server home path, for security reasons. When I try to retrieve the file on my development server everything works great, but when I try it on my account with HostGator it opens the PDF and I get an error after Adobe opens. "There was an error opening this document. The file is damaged and could not be repaired" Here is the code I'm using Code: [Select] $file = $file_info->file_name; if(file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/mime-type'); header('Content-Disposition: inline; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); } when I present it with a browser that is fails. I have been racking my brain for hours. I would appreciate some help. Thanks Troy Hi again! I'm trying to use this code that i found somewhere in the net to display all the dates between 2 dates. It is exactly what i need but.. I understand the code and its structure (i think) but it gives me an error (maximum execution time of blah blah) which i think is because it makes an infinite loop(not sure.. ) Code: [Select] function GetDays($sStartDate, $sEndDate) { $sStartDate = gmdate("Y-m-d", strtotime($sStartDate)); $sEndDate = gmdate("Y-m-d", strtotime($sEndDate)); $aDays[] = $sStartDate; $sCurrentDate = $sStartDate; while($sCurrentDate < $sEndDate){ $sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate))); $aDays[] = $sCurrentDate; } return $aDays; } Appreciate the help and suggestions! Gonna browse the forums for answers for the meantime... |