PHP - Changing Multiple Text Labels Dynamically
Hope I'm not in the wrong forum here as javascript is required, BUT my page is written in PHP and will need to work from any number of records from the database.
Basically, I have a drop-down box that contains product sizes, for example:- Small Medium Large Extra Large If the user selects Large for example, I want to change 'Was Price', 'Now Price' and 'Product Code' displayed on the page. If they select another size from drop-down the prices and code need to change again. Posted in the PHP section as PHP code is needed as well. Any help much appreciated. Similar TutorialsHi! I am currently making a really simple photo blog. The query fetches every reference to the images which are stored on the server. I have a problem when it comes to dynamically cycling through these though. After running the query, I store each image reference in a twodimensional array like this: [["id"], ["date"], ["title"], ["filename"]] (an Array of Arrays). The image displays just fine by doing this: $pointer; //starting from the last element (image) in the array <img src="images/gallery/<?php echo $images[3][$pointer] ?>" alt="<?php echo $images[2][$pointer] ?>"> The problem is that, when I update the pointer, say for instance pointer++, the current image on the screen doesnt update. I know for a fact that the pointer updates, because I have echoed it. The basic idea is to have a previous and next link just under the image, so that the viewer can cycle the available images. Any help is greatly appreciated hey i am using a MySql database and i need to create a dynamic HTML table with one of its columns as checkboxes.so i have to create multiple checkboxes.but these checkbox values are to be stored in a mysql table and then later retrieved when form reloads.and depending on previous state when form was submitted, the newly created checkboxes have to be checked in the same manner.so how do i store multiple checkbox values in my table and also how do i retrieve them? please help. im trying to get a different title when links like: site.com/?off, and site.com/?off1 display the same title, but ?on displays a diff title however, it doesnt seem to work properly, im using the code below: <?php if ((isset($_GET['off'])) && (isset($_GET['off1']))) echo "<title>Url - Statistics</title>" ?> <?php $link ='hits.php?on'; if (isset($_GET['on'])) echo "<title>Url - Statistics - Auto refreshing.....</title>" ?> thanks when i type site.com/?off into my browser, no title is displayed I am building an Event Registration system, and am thinking that it should put the Attendee's name on the Ticket (and in the database) as a backup. Is there a way to easily (and dynamically) display the same number of Text-Boxes as the # of Attendees entered? For example, let's say the Customer (payor) wants to buy Tickets for herself and 5 friends to a Banjo Festival. Right now, I just have a drop-down box to capture the head-count, but it would be nice to have 5 Text-Boxes (or something appear) so that the Customer can easily type in the Names of the 5 Attendees *without* having to suffer numerous other clicks and/or screens. Follow me? Is there a way to do that? Thanks, Debbie Hi guys i have to create text field & enter data and store in the data base. here im able to create text field but couldn't insert the data. so could anyone please check this code for me. <body> <form method="POST" action="cell.php"> Enter the number of question <input type="text" name="question"> <input type="submit"> <?php $value=$_POST['question']; for($i=0;$i<$value;$i++) { echo "Question NO:"; echo '<input type="text" name="qno">'."\t"; echo "Enter Marks:"; echo '<input type="text" name="marks">'."\t"; echo "<br>"; } ?> </form> <form name="form1" method="post" action="cellresult.php"> <label> <input type="submit" name="Submit" value="Submit"> </label> </form> </body> cellresult.php <body> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $sql="INSERT INTO cell (QNO,MARKS) VALUES ('$_POST[qno]','$_POST[marks]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> </body> my name is fairooj and ama new to php and jquery. i have a proplam. i want your help.
<script type="text/javascript"> var count = 0; $(function(){ $('p#add_field').click(function(){ count += 1; $('#container').append( '<strong>Link #' + count + '</strong><br />' + '<input id="field_' + count + '" name="fields[]' + '" type="text" />' + '<input id="code_' + count + '" name="code[]' + '" type="text" /><br />' ); }); }); </script> I have a site that I have an about page with pictures of people on it. I would like to create something that would do the following: * When you click on one of the images, i need text for that image to load in a text area. I would like to do this rather than have to make a different HTML page for each person, but I am not sure how to go about doing it. I do not have a database for this site, so I will need to pull the text from a text file or something like that. Any ideas on how to get started would be helpful. Thanks in advance! The Issue (note: sorry for double post in the regex forum.) My users can post comments. I want to turn the hidden links within those comments into clickable URLs. I have the following function to do this: Code: [Select] if (!function_exists('create_link')) { function create_link($url) { $pattern = "#((http|https|ftp)://(\S*?\.\S*?))(\s|\;|\)|\]|\[|\{|\}|,|\"|'|:|\<|$|\.\s)#ie"; $link_title = character_limiter(preg_replace($pattern, "$3", $url), 50); $link = preg_replace($pattern, "'<a href=\"$1\" target=\"_blank\">{LINK_TITLE}</a>$4'", $url); if ($link == $url) { $url = 'http://' . $url; $link = preg_replace($pattern, "'<a href=\"$1\" target=\"_blank\">{LINK_TITLE}</a>$4'", $url); } if ($link != $url) { $result = str_replace('{LINK_TITLE}', $link_title, $link); } else { $result = FALSE; } return $result; } } I know that the regex is pretty bad. It kind of works, but makes every single thing with a period into a link, and messes up sometimes with target= portion where it will actually display that. I've tried a bunch of other regex's but every single one gives me problems, typically like "php unknown modifier ]" or ")" or something. here's how I call this function when users hit submit in the comment field: Code: [Select] $words = preg_split("/[\s,]+/", $comment); foreach ($words as $word) { if ($link = create_link($word)) { $comment = str_replace($word, $link, $comment); I just want to convert the right links into links. is something like: ^(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$ any better? I don't know, nothing seems to work. Hi there! I found this code to parse a MySQL query to PDF, but it's for small address labels and I was wondering how to make it for 4x6 labels? <?php define('FPDF_FONTPATH','/home/directory/public_html/sub/font/'); require_once('fpdf.php'); //Connect to your database mysql_connect("localhost", "db_user","db_pw") or die ("Could not connect to database"); mysql_select_db("database_name") or die ("Could not select database"); $query = "SELECT employee_name, street_address, City, state, zip_code FROM employees ORDER BY `employee_name` "; $result = mysql_query($query) or die('Error, query failed'); $num_rows = mysql_num_rows($result); function PrintAddressLabels($result){ $pdf=new FPDF(); $pdf->Open(); $pdf->AddPage(); $pdf->SetFont('Arial','B',14); $pdf->SetMargins(0,0); $pdf->SetAutoPageBreak(false); $x = 0; $y = 0; $i=0; while (TRUE) { if ($row=$result[$i]) { //positions set above $LabelText = sprintf("%s\n%s %s\n%s, %s, %s", $row['employee_name'], $row['street_address'], $row['City'], $row['state'], $row['zip_code']); Avery5160($x,$y,&$pdf,$LabelText); $y++; // next row if ($y == 10 ) { // end of page wrap to next column $x++; $y = 0; if ($x == 3 ) { // end of page $x = 0; $y = 0; $pdf->AddPage(); } } $i++; //counter through result } else { // Error quit printing break; } { $pdf->Output('mailing_labels.pdf','D'); } ?> Does anyone know where I can find some good resources/tutorials that covers how to use the PDF stuff with PHP or know how I can change this up to match for 4x6 at all? Any help or info is greatly appreciated! Thanks! I have a recursive sql query. I'm doing this with an sql query as a function. Here is the function: function select() { $sql="SELECT cat FROM $scat"; if($result=$mysqli->query($sql)){ if($result->num_rows>0){ $level =+1; echo<<<HTML <div class="menutitles"> onmouseover="document.getElementById('$scat').style.display='block';document.getElementById('$scat2').style.display='block';" onmouseout="document.getElementById('$scat').style.display='none';document.getElementById('$scat2').style.display='block';" > <a class="topseltxt2" href="gem.php?cat=$scat"></a><br/> <div class="contain" id="$scat"> <div class="menuitems" id="$scat2"> HTML; select(); }else{$level=-1; if($level==1){echo" <a class='topseltxt' href='gem.php?cat=$scat'></a><br/> "; }else{ While($row=$result->fetch_array()){ $scat=replace($row[cat]); echo" <a class='topseltxt2' href='gem.php?cat=$scat'></a><br/> ";} } } } } and this is the database query with the function added to it: $level=1; $count=0; $sql = "SELECT cat FROM dczcat1 ORDER BY position"; if ($result = $mysqli->query($sql)){ if ($result->num_rows > 0){ $count=+1; while ($row = $result->fetch_array()){ $scat=replace($row[cat]); $scat2=replace($row[cat]) . 2; $cat=$row[cat]; $sql="SELECT cat FROM $scat"; if($result=$mysqli->query($sql)){ $count=+1; if($result->num_rows>0){ $level =+1; echo<<<HTML <div class="menutitles"> onmouseover="document.getElementById('$scat').style.display='block';document.getElementById('$scat2').style.display='block';" onmouseout="document.getElementById('$scat').style.display='none';document.getElementById('$scat2').style.display='block';" > <a class="topseltxt2" href="gem.php?cat=$scat"></a><br/> <div class="contain" id="$scat"> <div class="menuitems" id="$scat2"> HTML; select(); }else{$level=-1; if($level==1){echo" <a class='topseltxt' href='gem.php?cat=$scat'></a><br/> "; }else{ While($row=$result . $count->fetch_array()){ $scat=replace($row[cat]); echo" <a class='topseltxt2' href='gem.php?cat=$scat'></a><br/> ";} } } }echo"</div> </div> </div>"; } } } I get the error: Fatal error: Call to a member function fetch_array() on a non-object in /home/kangerc1/public_html/zleftsidebar.php on line 60 I think this is because I am using $result more than once and I need to call it $result1 $result2 $result3 etc. but how can I generate the name of the variable? Like many projects, this started small, and keeps growing! I am building a photo gallery and would now like to add labels/captions below each photo, HOWEVER, I really don't want to have to build a database and do all the related coding. (I know how, but its a PITA.) To display photos in the gallery, I read in files from my "images/" directory, store them in a simple array, and then iterate through the array to display the thumbnails in a gallery. I am wondering if there would be an easy way that I could merge photo metadata (e.g. a brief caption) with my array or something like that? If I could type up the file names and a brief description/caption in a Text File or Spreadsheet and then somehow slurp that into my code and merge it with my array or something like that, then I would be willing to type up captions. (This is for like 600 photos which is why I don't want to do a database as data entry in phpMyAdmin is a PITA!) Any suggestions how I could do this and add a "cherry on the top" of this mini project I am doing for my co-workers? Thanks!
hi, whats the best way to print labels. I have already tried the script from fpdf.de but i can not get my dot matrix printer (dot matrix is needed for this purpose) the correct layout. Its continuous paper, with size 110 height x 62mm width (for each label). I am not able to select a self-adjustable paper-size. so i hope to solve this with PHP / PDF if possible. anyone have experience with this? cheerz!! I use the following code to generate a scrollable checkbox list of options: Code: [Select] <html> <form action="SCRIPT.php"> <?php $expList = array('Engineering ','Science', 'Art', 'IT', 'Electronics', 'Communications'); sort($expList); $tmp = array(); $i = 1; $tmp[] = '<ul style="height: 95px; overflow: auto; width: 200px; border: 1px solid #480091; list-style-type: none; margin: 0; padding: 0;">'; foreach ($expList as $option) { $tmp[] = '<li id="li' . $i . 'b"><label for="chk' . $i . 'b"><input name="chk' . $i . 'b" id="chk' . $i . 'b" type="checkbox" onchange="Enable(\'chk' . $i . 'b\',\'li' . $i . 'b\')">' . $option . '</label></li>'; $i++; } $tmp[] = '</ul>'; echo implode("\n",$tmp) . "\n"; ?> <input type="submit"> </form> </html> But there are in fact over 50 options (not just 6) and they are in fact stored in an array $expList in an external php file called LISTS.php. As you can see, the checkbox list consists of checkboxes chk1b, chk2b, chk3b, etc. with associated labels (Art, Communications, Electronics, etc.). What I need in SCIPT.php is code that will insert each of the labels where the associated checkbox has been checked in my MySQL database. E.g. in this particular case: if chk1b & chk3b have been checked, 'Art' & 'Electronics' will be inserted. Also, I want the label of the first checked checkbox to be inserted in the (database) table column 'Exp1', the 2nd one in 'Exp2'.........25th one in 'Exp25' (I already have a script that allows a maximum of 25 checkboxes to be checked). I'm guessing some sort of 'foreach' loop is required, but I can't quite work it out. Pls help! Many thanks! Hi All, If someone types in my textarea without any hard returns, it echos the entire text on a single line, which expands my site very very far and screws up the layout. how can I echo the text but limit the number of characters per line before I insert my own line break? The code is just: Code: [Select] echo $message; I have problem that only last text field is updated, how should I fix this? Here's the code <?php if(isset($_POST["update"])){ mysql_query("UPDATE categories SET name_category = '".$_POST['category']."' WHERE ID= ".$_POST['currentCat']." ") or die(mysql_error()); mysql_query("UPDATE podkategorije SET name_subcategory = '".$_POST['subcategory']."' WHERE id_subCat= ".$_POST['currentSubCat']." ") or die(mysql_error()); } ?> <form action="" method="post" > <?php //creating texfields from db $query = "SELECT k.ID, k.name_category, pk.name_subcategory, pk.id_subCat FROM `categories` AS k JOIN `subcategories` AS pk ON pk.id_mainCat = k.ID"; $result = mysql_query($query) or die(mysql_error()); $currentCat = false; while($row = mysql_fetch_array($result)) { //so it doesn't repeat itself if($currentCat != $row['ID']) { //display of main Categories ?> <ul> <li> <br/><input name="categories" type="text" value="<?php echo $row['name_category']; ?>" /> </li> </ul> <? $currentCat = $row['ID']; } //display subcategories ?> <input name="subcategories" type="text" value="<?php echo $row['name_category']; ?>" /><br/> <input type="hidden" name="currentCat" value="<?php echo $row['ID']; ?>" /> <input type="hidden" name="currentSubCat" value="<?php echo $row['id_subCat']; ?>" /> <? } ?> <br /> <input type="button" value="Back" onClick="history.go(-1);return true;"> <input type="submit" value="Update" name="update"/> </form> Hi guys, I am struggling with a form containing multiple checkboxes with corresponding textboxes. Eg.: there are 5 checkboxes (XS, S, M, L, XL) and 5 textboxes (with values 3,4,5,6,8) that correspond to the checkboxes. I give all the checkboxes the name 'size[]' and the textboxes the name 'price[]'. The aim is to have my script set a boolean to true and update the corresponding price if the checkbox is selected. Unfortunately it does not work this way: checkboxes are only put in the array when they are selected, meaning that if I select only checkbox S and L, the array length is 2 only, but array length price is always 5, so size[1] does not correspond to price[1] necessarily. There probably is a better way to achieve what I need. Could anyone point me in the right direction? edit: BTW the number of items is dynamic: sometimes there will also be XXL or some items will be missing and I also need to set the price for items where the checkbox is not checked. Hi, I need to build my own xml validator and was wondering, what are some possible purposes of having multiple text nodes for a given parent node, I ask b/c while I was playing around with W3schools XML validator, I noticed it successfully validated the following: <?xml version="1.0" encoding="utf-8" ?> <note> <to>Joh</to> <from>Frank</from> <body>Hello world</body> Extra text node that is validated! </note> Hi. I have just one question (I have searched for an answer for this but have not been able to locate one): How do you go about changing the text on a "Submit Query" button to display simply "Submit"? Below is the current code for the page that displays said button. Thank-you in advance for any help or direction. <?php include 'connection.php'; $query = "SELECT * FROM people"; $result = mysql_query($query) or die(mysql_error()); while ($person = mysql_fetch_array($result)){ echo $person ['name']; echo $person ['descrip']; } ?> <H1>Add Your Review:</H1> <form action="create.php" method="post"> Subject <input type="text" name="inputName" value=""/> </br > Review <textarea cols="50" rows="4" name="inputDesc" value=""/></textarea> </br > <input type= "submit" name= "submit"/> </form> <html> <head></head> <body> <p>The current second is <span style='font-size:16px;font-weight:bold;color:red;position:absolute;right:25px;'><?php echo time(); ?></span> on this computer.</p> </body> </html> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=326995.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=351561.0 |