PHP - Checking Id's To Create Or Append Tables
I am submitting $_POST data to a results page. The data comprises of references and text. Each reference has its own table on the results page. I need to check if an any of the table id's on the results page are the same as any of the references in $_POST, if any are, I am appending to the table, if not I am creatig a new table for the reference. How do I check if a table id exists in order to append, then create tables for those that don't Any help/guidance appreciated.
Similar TutorialsI am trying to create seperate tables from this. Maybe a div class will work. I want each cat variable 'catname' to be in seperate tables at the top of each table with the subcats for that cat in 1 or 2 rows under the cat. I want to be able to also choose whether to use 1 or 2 table rows for the subcats under the cat. any ideas? Will appreciate your help. // Categories $sql = "SELECT catid, catname AS catname FROM $t_cats WHERE enabled = '1' $sortcatsql"; $rescats = mysql_query($sql) or die(mysql_error()); $catcount = @mysql_num_rows($rescats); $percol_short = floor($catcount/$dir_cols); $percol_long = $percol_short+1; $longcols = $catcount%$dir_cols; $i = 0; $j = 0; $col = 0; $thiscolcats = 0; while($rowcat=mysql_fetch_array($rescats)) { if ($j >= $thiscolcats) { $col++; $thiscolcats = ($col > $longcols) ? $percol_short : $percol_long; $j = 0; echo "<td valign=\"top\" width=\"$cell_width%\">"; } $i++; $j++; $catlink = buildURL("ads", array($xcityid, $rowcat['catid'], $rowcat['catname'])); $adcount = 0+$catadcounts[$rowcat['catid']]; ?> <table border="0" cellspacing="0" cellpadding="0" width="100%" class="dir_cat"> <tr> <th width="25" valign="top"><img src="images/category.gif" border="0" align="absmiddle"></th> <th><a href="<?php echo $catlink; ?>"><?php echo $rowcat['catname']; ?></a> <?php if($show_cat_adcount) { ?><span class="count">(<?php echo $adcount; ?>)</span><?php } ?> </th> </tr> <?php $sql = "SELECT scat.subcatid, scat.subcatname AS subcatname FROM $t_subcats scat WHERE scat.catid = $rowcat[catid] AND scat.enabled = '1' $sortsubcatsql"; $ressubcats = mysql_query($sql) or die(mysql_error()."<br>$sql"); $subcatcount = mysql_num_rows($ressubcats); while ($rowsubcat = mysql_fetch_array($ressubcats)) { if ($shortcut_categories && $subcatcount == 1 && $rowsubcat['subcatname'] == $rowcat['catname']) { continue; } $adcount = 0+$subcatadcounts[$rowsubcat['subcatid']]; $subcat_url = buildURL("ads", array($xcityid, $rowcat['catid'], $rowcat['catname'], $rowsubcat['subcatid'], $rowsubcat['subcatname'])); ?> <tr> <td> </td> <td> <a href="<?php echo $subcat_url; ?>"><?php echo $rowsubcat['subcatname']; ?></a> <?php if($show_subcat_adcount) { ?><span class="count">(<?php echo $adcount; ?>)</span><?php } ?> <br> </td> </tr> <?php } ?> </table> <br> <?php if($j==$thiscolcats || $i==$catcount) echo "</td>"; } ?> </tr></table> Hello, well I guess my question is pretty clear. How would I be able to read data out of an Excel sheet? F.E. to allow my users to simply upload an .xls file to help them avoid the coding and such. Of course, I know how to create the tables etc, the main problem is just getting that data. Also, I am uncertain if uploading an .xls file is a lot harder/totally done differently then images, and if so.. what is the best way to do this? P.s. I do want all the fancy equations to be included, just normally entered data (which would just follow some sort of a protocol). Thanks in advance. i have two tables, employee details table(empno, emp_name , branch) and attendance table(date, Ot, attendence). I want to create a relation between two tables Hi,
I am a bit of a MYSQL newbie so please bear with me. I have a database created about football/soccer stats. The database at the moment contains the following tables but more maybe added:
Players
Clubs
Seasons
Competitions
I will create php pages for these tables that add, edit and delete records for each. But the problem I can't get my head around is how to add a record that uses data from other tables, for example we would add a...
player -> club-season-competition
Lets say we want create a player called 'Joe Bloggs' and want to add his details, we need somehow for the page to display an option for club, season and competition. Maybe they can be drop down boxes but how does one fill those drop down boxes with records that are already added in the database for each table?
Thanks
Here is function that backup mysql database. It's working fine, but I want to download file instead of creating it. /* backup the db OR just a table */ function backup_tables($host,$user,$pass,$name,$tables = '*') { $link = mysql_connect($host,$user,$pass); mysql_select_db($name,$link); //get all of the tables if($tables == '*') { $tables = array(); $result = mysql_query('SHOW TABLES'); while($row = mysql_fetch_row($result)) { $tables[] = $row[0]; } } else { $tables = is_array($tables) ? $tables : explode(',',$tables); } //cycle through foreach($tables as $table) { $result = mysql_query('SELECT * FROM '.$table); $num_fields = mysql_num_fields($result); $return.= 'DROP TABLE '.$table.';'; $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table)); $return.= "\n\n".$row2[1].";\n\n"; for ($i = 0; $i < $num_fields; $i++) { while($row = mysql_fetch_row($result)) { $return.= 'INSERT INTO '.$table.' VALUES('; for($j=0; $j<$num_fields; $j++) { $row[$j] = addslashes($row[$j]); $row[$j] = str_replace("\n","\\n",$row[$j]); if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; } if ($j<($num_fields-1)) { $return.= ','; } } $return.= ");\n"; } } $return.="\n\n\n"; } //save file $date= date("d-M-Y_h-i"); $handle = fopen('Backup-'.$date.'.sql','w+'); fwrite($handle,$return); fclose($handle); } Usage: Quote backup_tables('HOST','USER','PASS','TABLE'); But this will create backup file on server. I also tried to add following code in function (at the end): echo $return; header('Content-type: text/plain'); header("Content-Disposition: attachment; filename=\"$filename\""); How to just download file, without showing it on screen instead of using fwrite/fclose function? Though I've been tinkering with PHP for a number of years, I'm mostly a front end developer/designer (HTML5, XHTML, CSS). In other words, please go easy on me. I am working on a site where we're pulling data from mysql. Each row that has a column for dimensions which look like this: 20x10x5 Here's what I have so far: $dimensions = explode("x",$row['DIMENSIONS']); $x_separated = implode("x", $dimensions); echo "$x_separated"; What I would like to do is append an "inches" or "in" to each value in the array. The resulting values should look like this: => 20in [1] => 10in [2] => 5in And after the implode, would then look like this: 20in x 10in x 5in Any help from the more experienced coders here is much appreciated. Thanks! I am trying to create a webpage and I've added some jQuery to it but it is not working, can you help me out?
JS File:
$(document).ready(function() { $('#button').click(function() { var toAdd = $('input[name=add]').val(); $('.message').append("<li>" + toAdd + "</li>") }); });HTML: <html> <head> <title> Test page </title> <link rel="stylesheet" type="text/css" href="style.css"> <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> <script type='text/javascript' src='script.js'></script> </head> <body> <div class="top-section"> <div class="top-back"> <div class="tcontent"> <div class="tcontent-body"> <h1>Welcome to the Forum Pioneer Test Page</h1> <ul> <li>This will be a list of to do's.</li> <li>Add your own list below</li> </ul> <form> <input type="text" name="add" value="Type Here"> </form> <div id="button">Add</div> <div id="message">d</div> </div> </div> </div> </div> </body> </html>I've put only the elements that are affected. I try clicking the button, but the content isn't appended. Edited by PrinceTaz, 13 December 2014 - 12:55 PM. Trying to simply append each error message into the error.message div.
We can get only one of the error messages at time to display in notification div.
We just want each field with error to display in notification div.
Can anyone give some direction, we mssing:
Error Message loop
if((data.row_id).length > 0) { $.each(data, function(error_code, message ) { if(errorCode == $.trim(data.error_code) && errorCode != -1 ){ error_message = data.message; return false; } }); }Print out Error Message(display) var spanerrorgen = $('.error.message').contents().find('h4').html(error_message); var appenderrorgen = $('.error.message').contents().find('h4'); $($fieldref).each(function(){ $(spanerrorgen).append(appenderrorgen); }); errorFields.notify.showNotification(".error"); hi, i have this xml: <?xml version="1.0" encoding="ISO-8859-1" ?> - <link4> <nome>Tove</nome> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> <nome>sdsd</nome> <id>116</id> </link4> and i want simple append more elements "nome" and id inside of link4 how can i do that i using php 4 thanks a lot for your help I can't seem to find an answer on this one. I've figured out how to add key/value pairs, add to the beginning and end - but the question here is how do you append to each value within an array? Let's say I wanted to add the word 'go'. From: Array ( => Bruins [1] => Rangers [2] => Leafs ) To: Array ( => GoBruins [1] => GoRangers [2] => GoLeafs ) Seems simple enough but Google isn't being friendly today. We are getting back each error message, but it only outputs the last error message.
how can we append each error message to the DIV
Here is the code that loops thru each error message
if(data.length > 0) { $.each(data, function(error_code, message ) { if(errorCode == $.trim(message.error_code) && errorCode != -1 ){ error_message = message.message; return false; } }); }Here is the code that outputs the error message in a drop down. PLEASE ANY HELP if(BoltNotify === true && multipleNotice === true){ //var error_message += error_message; var spanerrorgen = $('.error.message').contents().find('h4').html(error_message); var appenderrorgen = $('.error.message').contents().find('h4'); $.each(data, function($fieldref) { $(spanerrorgen).append(spanerrorgen); }); VanillaReload.notify.showNotification(".error"); } i have a long list of numbers like this 36346346 436346 444444 44 666666666666865 4564 . . . and at the beginning and end of each entry i want to append some characters so it looks like this: -36346346+ -436346+ -444444+ -44+ how do to this with php? thanks I now know how to append GET over normal hyperlinks, but I don't know how to do it with form submissions. Here's the problem: I have a form like this one: <form method="GET" action=""> <?php require_once ('sort_category_func.php'); $switch = 1; sort_category ($switch); ?> + Most Liked <input type='checkbox' value='mostLiked' name='mostLiked' /> <br /> <input type="submit" name="sortSubmit" value='Go' /> <br /><br /> </form> And the variables: // DROP DOWN MENU VARIABLES $select_category = $_REQUEST['sort_category']; $most_liked = $_GET['mostLiked']; I'm using a while loop to list user submission, you can also sort them by category which works over GET, this works as long as there is no GET data already in the URL, but as soon as there is GET data it won't work anymore. Here's an example: If I have a user profile page opened like this: profile.php?user=konopkov And a category has been chosen to sort the user's submissions the URL will change to: profile.php?sort_category=Logos INSTEAD it should be: profile.php?user=konopkov&sort_category=Logos As I said I know how to achieve this with hyperlinks now, but I have no clue how do it with form submissions. Any suggestions? Thanks. Hi there, I am working on a page. That has all the products listed on it. Every product has a Shipping profile associated with it. Whenever a new product is created, we assign a Shipping profile to that new Product. And its product ID is then inserted into the Shipping profile table. Note: One Shipping Profile can have multiple Products under it. The scenario is that when we create the 2nd product and assign Shipping Profile and insert the 2nd product ID to Shipping Profile, the old value gets replaced with the new ProductID. We just need to somehow append the new ProductID to the existing ProductIDs in the Shipping Profile table. We can do an Update query but that will replace the Old Product ID with the new ProductID. Here we just need to append the new Product ID to the Old product ID. eg ............................... Shipping Profile Table| `````````````````` ShippingProfileID ProductID 1 1,4,6 2 3,7 Now at the moment, the ProductID gets stored but it just replaces the Old product ID. We just need to append to the existing IDs Any comments or feedback are always welcomed. Thank you! Hello there people. I'm looking for the easiest & most solid way to append 1 or 2 strings to a certain PDF file. I have an application which a logged-in user will be able to print. When he prints it, his name and a counter string must be appended in a blank space in the application. So I don't need to replace a string in a PDF or something, just append. The PDF file will always be the same: the application to be filled. I've heard somewhere that you can do it easily with the Zend framework. I've also heard for some other libraries like TCPDF & FPDF. Any suggestions? Thanks Hello, Firstly I am only just learning php so please bear with me. What I want to be able to do is for a user to be able to enter a youtube url eg: Code: [Select] http://www.youtube.com/watch?v=8xz7ShMCWls I want the scrip to take the video ID (after watch?v=) and append it into a html embed code for our forums that do not have the feature to auto embed a youtube vid. Code: [Select] <p> <img height="350" width="425" class="fw_media_youtube fw-parse" alt="YouTube-AFTER WATCH?V=CODE" src="http://thumbs.webs.com/Platform/mediaPreview.jsp?type=YouTube&id=AFTER WATCH?V=CODE"/></p> Where you see AFTER WATCH?V=CODE is where I want it to place the video id and then return this completed code for the user to copy and paste: Code: [Select] <p> <img height="350" width="425" class="fw_media_youtube fw-parse" alt="YouTube-8xz7ShMCWls" src="http://thumbs.webs.com/Platform/mediaPreview.jsp?type=YouTube&id=8xz7ShMCWls"/></p> How would I be able to get this done. I do not expect to be spoon fed but just a litlle help please. Thank you so much if you do help. hi all i'm trying to make a quick and simple '.htaccess' installer and i'm using fopen/fwrite to do this but i'm getting an error: Quote Parse error: parse error in /var/www/test.php on line 12 here's the code: Code: [Select] <?PHP $File = ".htaccess"; $fh = fopen($File, 'a'); $Data = "\n#test write <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript text/x-js text/ecmascript application/ecmascript text/vbscript text/fluffscript AddOutputFilterByType DEFLATE image/svg+xml application/x-font-ttf application/x-font font/opentype font/otf font/ttf application/x-font-truetype application/x-font-opentype application/vnd.ms-fontobject application/vnd.oasis.opendocument.formula-template AddOutputFilterByType DEFLATE text/xml application/xml </IfModule> <IfModule mod_expires.c> <FilesMatch "\.(ico|gif|jpg|JPG|jpeg|png|PNG|swf|css|js|html?|xml|txt)$"> ExpiresActive On ExpiresDefault "access plus 1 month" </FilesMatch> </IfModule> #test write\n"; fwrite($fh, $Data); fclose($fh); ?> how do i include the code in the $Data string bit? Hi, currently in my registration code, the userId allows only six digits as the user ID. I need help in performing the following task 1. Modify the account creation screen to allow users to enter EITHER a 6-digit ID OR a 9 character ID. Any 6-digit PLID will be stored with the perpended B11. 2.Modify the login utility for the users to allow them to use either the 6-digit or 9-character IDs which means you will need to prepend the B11 to any 6-digit PLID to find their record in the database. 3.Convert existing PLIDs in the database to the new format by prepending the B11. Any coding help will be greatly appreciated. I append a string to a file by fwrite as Code: [Select] $str= 'dynamic text from each run'; $myFile = "testFile.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "$str\n"; fwrite($fh, $stringData); fclose($fh); but I want to avoid duplicate to keep the file small. I want to avoid writing if the term is already saved in the file. I want to have a file containing unique lines. hello i can't figure out how to modify a value from assoc array so with each recursion to add additional string to his: for example i have attribute=""; then call recursive function and i try to modify its value by concatenating "0"; or "1"; on the next loop to add again "0" or "1"; |