PHP - Maintaining Tables Using Html
I am trying to create a very basic webpage (for local use) that will allow me to add records to a table that I can then come back to at a later date. Essentially, I want a mini spreadsheet in a HTML file. Is this possible?
I know that I could do this using PHP, but I just want this for local use, so I do not want / need to upload it anywhere. Plus, I am not linking to any database, I am hoping just to have the table saved into the HTML file. I currently have a JS script that will add rows to my table (with predetermined information - not 100% what I am wanting), but once I close the window, that information is not saved. If anyone could at least point me in the right direction, that would be good (hopefully this all makes sense) Similar Tutorials$count=0; $numb=50; foreach ($sepkeys as $dbkey) { for ($page=10;$page<=$numb;$page=$page + 10) { // the if block $count=$count+1; } } I am trying to maintain a separate a count for each key number in the above code. Eg: key- 574, it searches from pages 10-50 and increments the count by 1. The problem that I have is the count is continuous. After searching for the first key and moves on to the next key and them I need the count to start from the beginning rather than being continuous. Eg: key-874 : count = 22, in my case the next key 875 : the count is 23 I need to make it 1. I removed the if block and several lines because the code is too long. Can someone please suggest me a way how to do it If I put into the database this string: Call the wife's son tomorrow How do I put it in to keep that apostrohe (wife's) and then when I retrieve it, also keep it without it displaying as wife/'s If I use stripslashes I think that just gets rid of the slash, but I want to KEEP the slash (but still protecting the database so it is not seen as a quote by the php code). I hope this is clear :-) Hi I am developing a e-commerce website. The user logs in and buy a product when he checkout the page will redirect to the payment gateway. After the payment is completed it will return back to my website. This is ok. But when it is returning back the session maintained in my website get lost. This happen only for the first time. If the user again logged in and checkout the process works good and the session is maintaining. Why does the session lost for first time. I used session_start() in all the pages.. I cannot find the solutions. Kindly help.. Regards P.Balakrishnan Hi, I have managed to get the code below working with a few tweaks here and there. However, you can see that I have written a small function in the file name local.php to allow the user to select "English" or "German" in the link on the test.php page. This works fine but it will only work on that particular webpage. As soon as I move away from that page the locale will return back to "en_US"(English). Is there a way I could implement lets say an option dropdown and save the locale across the whole site. Just in case its relevant I have a MySQL DB available for use if thats appropriate. local.php <?php function english(){ $directory = dirname(__FILE__).'/locale'; $domain = 'messages'; $locale ="en_UK.utf8"; setlocale( LC_MESSAGES, $locale); bindtextdomain($domain, $directory); textdomain($domain); bind_textdomain_codeset($domain, 'UTF-8'); } function german(){ $directory = dirname(__FILE__).'/locale'; $domain = 'messages'; $locale ="de_DE.utf8"; setlocale( LC_MESSAGES, $locale); bindtextdomain($domain, $directory); textdomain($domain); bind_textdomain_codeset($domain, 'UTF-8'); } //Pagination and normal view switch if (isset($_GET['run'])) $linkchoice=$_GET['run']; else $linkchoice=''; switch($linkchoice){ case 'English' : english(); break; case 'German' : german(); break; default : english(); break; } ?> test.php <?php include("local.php"); ?> <html><head></head> <body> <?php echo "<p><a href='?run=English'>English</a> | <a href='?run=German'>German</a> </p>"; ?> <br /> <?php echo gettext("Welcome to My PHP Application"); echo "<br />"; // Or use the alias _() for gettext() echo _("Have a nice day"); ?> </body> </html> Many thanks in advance! Hey, I want to be able to have a 100x100 thumbnail of pictures I am uploading while cropping the image to maintain the ratio. Right now I am stretching the image and it looks bad but it works. Here is my code... Quote $new_thumb = "$new_pic"; $sourcefile = "$target2$pic"; $picsize = getimagesize("$target2$pic"); $source_x = $picsize[0]; $source_y = $picsize[1]; $dest_x = 100; $dest_y = 100; $targetfile = "$thumbs$pic"; $pathtofile = pathinfo($sourcefile); $extension = $pathtofile['extension']; $jpegqual = 75; if($extension=='jpg' || $extension=='jpeg' || $extension=='JPG') { $source_id = imagecreatefromjpeg("$target2$pic"); $target_id = imagecreatetruecolor($dest_x, $dest_y); $target_pic = imagecopyresized($target_id,$source_id,0,0,0,0,$dest_x,$dest_y,$source_x,$source_y); imagejpeg($target_id,"$targetfile",$jpegqual); } if($extension=='gif') { $source_id = imagecreatefromgif("$target2$pic"); $target_id = imagecreatetruecolor($dest_x, $dest_y); $target_pic = imagecopyresized($target_id,$source_id,0,0,0,0,$dest_x,$dest_y,$source_x,$source_y); imagegif($target_id,"$targetfile",$jpegqual); } if($extension=='png') { $source_id = imagecreatefrompng("$target2$pic"); $target_id = imagecreatetruecolor($dest_x, $dest_y); $target_pic = imagecopyresized($target_id,$source_id,0,0,0,0,$dest_x,$dest_y,$source_x,$source_y); imagepng($target_id,"$targetfile",$jpegqual); } How could I change this to make the thumbnails maintain the aspect ratio but still be 100x100? This is a LINK to the page -> http://shoutkey.com/carriage I have a problem of separating MySQL concatenated info, yet still maintaining their relationship to other arrays in the same order. First off here is the MySQL code: Code: [Select] $query ="SELECT report,"; $query.="GROUP_CONCAT(DISTINCT docID) AS docIDs, "; $query.="GROUP_CONCAT(DISTINCT analyst) AS analysts, "; $query.="GROUP_CONCAT(DISTINCT region) AS regions, "; $query.="GROUP_CONCAT(DISTINCT country) AS countries, "; $query.="GROUP_CONCAT(DISTINCT topic) AS topics, "; $query.="GROUP_CONCAT(DISTINCT date) AS dates, "; $query.="GROUP_CONCAT(DISTINCT event) AS events, "; $query.="GROUP_CONCAT(DISTINCT link) AS links, "; $query.="GROUP_CONCAT(DISTINCT province) AS provinces "; $query.="FROM reports GROUP BY report ORDER BY dates DESC, docIDs DESC"; The most important thing is to get all attributes about each report. The thing is, each report can have as many records as it must, in order to store various types of information, like, if multiple analysts are working on the report, then each one saves their own record, but when retrieving these records MYSQL concatenates the records, to make it look to the analysts like this Report 1 --- Josh, Rebecca --- Philippines However, my problem is trying to display the reports by country... as you can see http://shoutkey.com/carriage. I have no idea about how to split up the countries, while maintaining their relationship to the $rows pulled from MySQL. I am gonna post the entire code, and let me know if anybody has any ideas. Code: [Select] $result = mysql_query($query); $numrows = mysql_affected_rows(); $current = false; while($row=mysql_fetch_assoc($result)) { $dates = $row['dates']; $analysts = $row['analysts']; $provinces = $row['provinces']; $topics = $row['topics']; $regions = $row['regions']; $countries = $row['countries']; $reports = $row['report']; $links = $row['links']; $events = $row['events']; if (!$current){ //first call echo "<h3><a href=\"#\">{$countries}</a></h3>"; //echo first call $current = $countries; echo "<div>" ;//open content div } elseif($current != $countries){ // country has changed echo "</div>"; //close previous content div echo "<h3><a href=\"#\">{$countries}</a></h3>"; //echo subsequent countries $current = $countries; echo "<div><p>" ;//open content div } echo $analysts." ----- ".$provinces." ----- ".$reports; echo "<br /><br />"; } echo "</div>"; ?> </div> Hi, So i have HTML table which i'm attempting to turn into executable SQL code which i can then insert into a SQL database table. I'm wondering if anyone has any good ideas for the best way to get this done? I need to extract the data from each of the <tr bgcolor="#EEEEEE">, scrape the text within each <td></td> and then format it in sql. so far i have removed the html not required and created an array by exploding "<tr bgcolor="#EEEEEE">", however, its creating an empty element in the first array index [0], to fix this i have tried $players = array_shift($players); however it removed everything from the array. next i was thinking i would need to remove all html within each array element and add a comma to the end, then i would need to compress it all back together again? would this be the best way to do this? source html <html> <head> <title><br/></title> <style type ="text/css"> body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } th { padding: 5px; text-align: left; } td { padding: 2px; border-style: solid; border-width: 1px } </style> </head> <body> <center><B><br/> </center></B> <p> <table bordercolor="#000000" width="90%" align="center"> <tr bgcolor="#EEEEEE"> <th>UID</th> <th>Name</th> <th>Nat</th> <th>Position</th> <th>Best Pos</th> <th>Age</th> <th>DoB</th> <th>Height</th> <th>Weight</th> <th>Expires</th> <th>Wage</th> <th>Value</th> <th>Aer</th> <th>Cmd</th> <th>Com</th> <th>Ecc</th> <th>Han</th> <th>Kic</th> <th>1v1</th> <th>Pun</th> <th>Ref</th> <th>TRO</th> <th>Thr</th> <th>Cor</th> <th>Cro</th> <th>Dri</th> <th>Fin</th> <th>Fir</th> <th>Fre</th> <th>Hea</th> <th>Lon</th> <th>L Th</th> <th>Mar</th> <th>Pas</th> <th>Pen</th> <th>Tck</th> <th>Tec</th> <th>Agg</th> <th>Ant</th> <th>Bra</th> <th>Cmp</th> <th>Cnt</th> <th>Dec</th> <th>Det</th> <th>Fla</th> <th>Ldr</th> <th>OtB</th> <th>Pos</th> <th>Tea</th> <th>Vis</th> <th>Wor</th> <th>Acc</th> <th>Agi</th> <th>Bal</th> <th>Jum</th> <th>Nat</th> <th>Pac</th> <th>Sta</th> <th>Str</th> </tr> <tr bgcolor="#EEEEEE"> <td>859596</td> <td>Tim Krul</td> <td>NED</td> <td>GK</td> <td>GK</td> <td>31</td> <td>3/4/1988 (31 years old)</td> <td>194 cm</td> <td>83 kg</td> <td>30/6/2022</td> <td>£25,000 p/w</td> <td>£12.75M</td> <td>15</td> <td>13</td> <td>14</td> <td>8</td> <td>13</td> <td>13</td> <td>15</td> <td>12</td> <td>16</td> <td>15</td> <td>12</td> <td>1</td> <td>2</td> <td>1</td> <td>3</td> <td>8</td> <td>4</td> <td>5</td> <td>3</td> <td>2</td> <td>2</td> <td>9</td> <td>4</td> <td>3</td> <td>8</td> <td>11</td> <td>12</td> <td>14</td> <td>13</td> <td>13</td> <td>12</td> <td>14</td> <td>2</td> <td>14</td> <td>2</td> <td>15</td> <td>10</td> <td>5</td> <td>13</td> <td>11</td> <td>13</td> <td>14</td> <td>17</td> <td>13</td> <td>8</td> <td>14</td> <td>10</td> </tr> <tr bgcolor="#EEEEEE"> <td>5204730</td> <td>Michael McGovern</td> <td>NIR</td> <td>GK</td> <td>GK</td> <td>34</td> <td>12/7/1984 (34 years old)</td> <td>188 cm</td> <td>86 kg</td> <td>30/6/2021</td> <td>£8,000 p/w</td> <td>£875K</td> <td>12</td> <td>11</td> <td>10</td> <td>2</td> <td>12</td> <td>12</td> <td>12</td> <td>11</td> <td>13</td> <td>8</td> <td>10</td> <td>5</td> <td>2</td> <td>1</td> <td>3</td> <td>9</td> <td>7</td> <td>6</td> <td>3</td> <td>3</td> <td>2</td> <td>7</td> <td>1</td> <td>2</td> <td>5</td> <td>7</td> <td>12</td> <td>14</td> <td>13</td> <td>13</td> <td>11</td> <td>17</td> <td>1</td> <td>12</td> <td>7</td> <td>12</td> <td>15</td> <td>10</td> <td>15</td> <td>10</td> <td>13</td> <td>12</td> <td>12</td> <td>12</td> <td>8</td> <td>15</td> <td>14</td> </tr> </table> <p> <p align="center"> </body> </html>
code i've created so far: <?php // Defining the basic scraping function function scrape_between($data, $start, $end) { $data = stristr($data, $start); // Stripping all data from before $start $data = substr($data, strlen($start)); // Stripping $start $stop = stripos($data, $end); // Getting the position of the $end of the data to scrape $data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrape return $data; // Returning the scraped data from the function } $myfile = fopen("source.html", "r") or die("Unable to open file!"); $page = fread($myfile,filesize("source.html")); $page = scrape_between($page, '</tr>', '</table>'); $players = explode('<tr bgcolor="#EEEEEE">', $page); echo '<pre>'; print_r($players); echo '</pre>'; fclose($myfile); ?> Edited December 14, 2019 by seany1234 i've been able to load up a csv file and display it as a html table but what i'm having trouble with is sorting it out with headings a to z but what i am trying to do is have 4 columns like this. Surgestions about how to do what im after i was hoping i could span the say A across all columns and centering them in the future also but thats not really the problem mainly the getting the array of the csv file and code right iguess. any help would be appreciated Code: [Select] <table> <tr> <th>A</th> </tr> <tr> <td>Apple1</td> <td>Apple2</td> <td>Apple3</td> <td>Apple4</td> <td>Apple5</td> <td>Apple6</td> </tr> <tr> <th>B</th> </tr> <td>Banana1</td> <td>Banana2</td> <td>Banana3</td> <td>Banana4</td> <td>Banana5</td> <td>Banana6</td> <tr> <th>C</th> </tr> <td>Cold1</td> <td>Cold2</td> <td>Cold3</td> <td>Cold4</td> <td>Cold5</td> <td>Cold6</td> </table> This is the code for inputting of the csv file i also have some other code i was wanting to use for the sorting of the array data from the csv file i'll past below.... Quote <?php $file = "widgets.csv"; $delimiter = ","; $enclosure = '"'; $column = array("", "", "", ""); @$fp = fopen($file, "r") or die("Could not open file for reading"); while (!feof($fp)) { $tmpstr = fgets($fp, 100); $line[] = preg_replace("/r/", "", $tmpstr); } for ($i=0; $i < count($line); $i++) { $line[$i] = explode($delimiter, $line[$i]); } ?> <html> <head> <title>Albert's Delimited Text to HTML Table Converter</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="1" cellpadding="5" cellspacing="0"> <tr> <?php for ($i=0; $i<count($column); $i++) echo "<th>".$column[$i]."</th>"; ?> </tr> <?php for ($i=0; $i < count($line); $i++) { echo "<tr>"; for ($j=0; $j < count($line[$i]); $j++) { echo "<td>".$line[$i][$j]."</td>"; } echo "</tr>"; } fclose($fp); ?> </table> </body> </html> Heres the code for the sorting of the table data from the array Quote <?php echo "QUERY_STRING is ".$_SERVER['QUERY_STRING']."<p>"; $rev=1; $sortby=0; if(isset($_GET['sortby']))$sortby = $_GET['sortby']; if(isset($_GET['rev']))$rev = $_GET['rev']; //Open and read CSV file example has four columns $i=-1; $ff=fopen('widgets2.csv','r') or die("Can't open file"); while(!feof($ff)){ $i++; $Data[$i]=fgetcsv($ff,1024); } //Make columns sortable for each sortable column foreach ($Data as $key => $row) { $One[$key] = $row[0]; // could be $row['Colname'] $Two[$key] = $row[1]; //numeric example $Three[$key] = $row[2]; $Four[$key] = $row[3];} //numeric example //Case Statements for Sorting switch ($sortby){ case "0": if($rev=="1")array_multisort($One, SORT_NUMERIC, $Data); //SORT_NUMERIC optional else array_multisort($One, SORT_NUMERIC, SORT_DESC,$Data); $rev=$rev*-1; break; case "1": if($rev=="1")array_multisort($Two, $Data); else array_multisort($Two, SORT_DESC, $Data); $rev=$rev*-1; break; case "2": if($rev=="1")array_multisort($Three, SORT_NUMERIC, $Data); else array_multisort($Three, SORT_NUMERIC, SORT_DESC,$Data); $rev=$rev*-1; break; case "3": if($rev=="1")array_multisort($Four, $Data); else array_multisort($Four, SORT_DESC, $Data); $rev=$rev*-1; break;} echo ("<table border=2>"); //$rev is reverse variable echo ("<th><a href=\"SortTable.php?sortby=0&rev=$rev\" title=\"Click to Sort/Reverse sort\">One</a></th>"); echo ("<th><a href=\"SortTable.php?sortby=1&rev=$rev\" title=\"Click to Sort/Reverse sort\">Two</a></th>"); echo ("<th><a href=\"SortTable.php?sortby=2&rev=$rev\" title=\"Click to Sort/Reverse sort\">Three</a></th>"); echo ("<th><a href=\"SortTable.php?sortby=3&rev=$rev\" title=\"Click to Sort/Reverse sort\">Four</a></th>"); $i=0; foreach($Data as $NewDat){ if($NewDat[0]!=""){ //error trap $str="<tr>"; foreach($NewDat as $field)$str.="<td>$field</td>"; $str.="</td>\n"; echo $str;}} fclose($ff); echo "</table>"; Hi, I have successfully implemented a master details page with the results aligned in columns linking to a details page. I wish to maintain the recordID passed from the master details page and make the dynamic text, which reads Shade A tree that is capable of..... in the attached screen shot a link to another details page referencing the same recordID. The detailspage2.php would look the same as the screenshot except the Shade text and description below will be highlighted, which I can do, there will be a new image and a new image description. All other dynmaic elements on the page will remain the same. I tried to simply save as my detailspage.php to detailspage2.php and create a link to detailspage2.php. It linked to detailspage2.php but none of the record info showed up in their respective table cells. I have all the names desc's, images, etc setup in a table in my database. Please let me know what code and other info you need to help me out with this procedure. Thanks. Hi there,
My friend asked me to help him perform a task today and I was completely stumped as to how I should complete it. Being someone who is reasonably experienced with PHP programming I didn't think I would find it absolutely impossible to complete, maybe hard, but not impossible. So I wondered if someone would now be able to explain to me in order to assist me in expanding my knowledge how to complete this task.
https://www.dropbox....B8M6cr_z7a?dl=0
Here is a link to the files he sent me, please ignore the C++ section.
If anyone could help / begin to give an explanation please fire away. I feel so bad about myself for NOT knowing that I'm now motivated to learn more!
Many thanks!
This portion is kind of stumping me. Basically, I have a two tables in this DB: users and users_access_level (Separated for DB normalization) users: id / username / password / realname / access_level users_access_level: access_level / access_name What I'm trying to do, is echo the data onto an HTML table that displays users.username in one table data and then uses the users.access_level to find users_access_level.access_name and echo into the following table data, I would prefer not to use multiple queries if possible or nested queries. Example row for users: 1234 / tmac / password / tmac / 99 Example row for users_access_level: 99 / Admin Using the examples above, I would want the output to appear as such: Username: Access Name: Tmac Admin I am not 100% sure where to start with this, but I pick up quickly, I just need a nudge in the right direction. The code I attempted to create just shows my lack of knowledge of joining tables, but I'll post it if you want to see that I did at least make an effort to code this myself. Thanks for reading! Im doing a search system and Im having some problems.
I need to search in two tables (news and pages), I already had sucess doing my search system for just one table, but for two tables its not easy to do.
I already use a select statment with two tables using UNION because I want to show number of search results, that is number of returned rows of my first sql statment.
But now I need to do a select statment that allows me to acess all fields of my news table and all fields of my pages table.
I need to acess in my news table this fields: id, title, content, link, date, nViews
I need to acess in my pages table this fields: id, title, content, link
Im trying to do this also with UNION, but in this case Im not having any row returning.
Do you see what I have wrong in my code?
<?php //first I get my $search keyword $search = $url[1]; $pdo = connecting(); //then I want to show number of returned rows for keyword searched $readALL = $pdo->prepare("SELECT title,content FROM news WHERE title LIKE ? OR content LIKE ? UNION SELECT title,content FROM pages WHERE title LIKE ? OR content like ?"); $readALL->bindValue(1,"%$search%", PDO::PARAM_STR); $readALL->bindValue(2,"%$search%", PDO::PARAM_STR); $readALL->bindValue(3,"%$search%", PDO::PARAM_STR); $readALL->bindValue(4,"%$search%", PDO::PARAM_STR); $readALL->execute(); //I show number of returned rows echo '<p>Your search keyword returned <strong>'.$readALL->rowCount().'</strong> results!</p>'; //If dont return any rows I show a error message if($readALL->rowCount() <=0){ echo 'Sorry but we didnt found any result for your keyword search.'; } else{ //If return rows I want to show, if it is a page result I want to show title and link that I have in my page table //if it is a news result I want to show title and link that I have in my news table and also date of news echo '<ul class="searchlist">'; $readALL2 = $pdo->prepare("SELECT * FROM news WHERE status = ? AND title LIKE ? OR content LIKE ? LIMIT 0,4 UNION SELECT * FROM pages where title LIKE ? OR content LIKE ? LIMIT 0,4"); $readALL2->bindValue(1, '1'); $readALL2->bindValue(2, "%$search%", PDO::PARAM_STR); $readALL2->bindValue(3, "%$search%", PDO::PARAM_STR); $readALL2->bindValue(4, "%$search%", PDO::PARAM_STR); $readALL2->execute(); while ($result = $readALL2->fetch(PDO::FETCH_ASSOC)){ echo '<li>'; echo '<img src="'.BASE.'/uploads/news/'.$result['thumb'].'"/>'; echo '<a href="'.BASE.'/news/'.$result['id_news'].'">'.$result['title'].'</a>'; //if it is a news result I also want to show date on my list //echo '<span id="date">'.$result['date'].'</span>'; echo '</li>'; } echo ' </ul>'; //but how can I do my select statement to have access to my news table fields and my page table fields?? } ?> I am trying to write some data from multiple SQL tables to a page. In the first table is a list of places. I then have more tables that are named after the different places. For example, say my first place in the list is called Place1. I have a table named Place1 with data that corresponds to place1. The data contained in the table named Place1 is a list of things to do in this place. It has 21 columns and each one is something to do in the morning, afternoon, and at night for each day of the week in the place Place1. What I am trying to do is display a sort of weekly calendar as a table on a webpage that lists all of the places in one column and then lists seven days of the week as 7 more columns. Then in each data cell I would want to list the things to do in the morning, afternoon and at night for the certain day of the week and for the place. The problem is that I am creating a CMS to allow other users with no coding knowledge to update events for other places, so I have to display data that could have been altered. The only solution I know of is to do a while loop that gets all of the place names and while there are still place names, write the place names to the page and set a variable equal to the place name. Inside the while loop I would create another while loop that each time the first while loop is executed uses the variable set in the first while loop to know which table to reference and then make a call to that table pulling out the 21 columns and writing them to the page. Each time the outer while loop executes, it would (hopefully) write the place name, and then set the variable as the current place name so that the inner while loop uses the variable to write the rest of the information about that place. I don't know if that would even work and if it did, I know it cannot be the best way to do this. I am pretty stuck here and don't really have a good solution so if anyone proposes a solution that is radically different to anything I have done, I am open to everything. Thank you! I want to read records from the database and print out in this table and I need help with the code. Code: [Select] <?php mysql_connect(localhost,root,""); mysql_select_db(oodb) or die( "Unable to select database"); $query=" SELECT * FROM oocust"; $result=mysql_query($query); $num=mysql_numrows($result); ?> <HTML><HEAD> <script type="text/javascript"> var monthNames = [ "January","February","March","April","May","June","July", "August","September","October","November","December" ]; var today = new Date(); var mmyy = monthNames[today.getMonth()] + " / " + today.getFullYear(); </script> </HEAD><BODY bgcolor="#CCCC99" background="oldorchard.jpg"><b><center> <font size=+2><b> Old Orchard Invoice </font>Date: <script type="text/javascript">document.write(mmyy);</script></center> echo "<TABLE BORDER="0" CELLPADDING="5" CELLSPACING="5" background="oldorchard.jpg"> <TD> <TABLE BORDER="0" CELLPADDING="10" CELLSPACING="10" background="oldorchard.jpg"> <TD> <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" background="oldorchard.jpg"> <TD> <input type=text size=25 value="Old Orchard Plumbing"><br> <input type=text size=25 value="2210 E. Hogan Hollow Road"><br> <input type=text size=25 value="Margate, Fl 33063"><br></TD> <TR> <td> <input type=text size=3 value="Bill To:"><br> <input type=text size=25 value="$bname"><br> <input type=text size=25 value="$bstreet:">><br> <input type=text size=25 value="$bcity"><br> <input type=text size=25 value="$contact"><br></TD> <tr> <td> <input type=text size=5 value="Ship To:"><br> <input type=text size=25 value="$sname:"><br> <input type=text size=25 value="$street"><br> <input type=text size=25 value="$scity"></td> </TR> </TABLE> </TD> <TD> <input type=text size=25 value="Invoice No: $invnum"><br> <input type=text size=25 value="Date: $mm/dd/yyyy"><br> <input type=text size=25 value="Terms: $terms"><br> <input type=text size=25 value="Due Date: $duedate"><br> <input type=text size=25 value="Order No: $ordernum"><br> <input type=text size=25 value="Territory:"><br> <input type=text size=25 value="Salesperson:"><br> </TD> </TABLE> </TD> <TD align=center><img src="dave pic.jpg" width=250 height=350></td> </TABLE> echo "</tr>"; <hr> echo "</table>";mysql_close(); ?> </b></BODY></HTML> Hi everyone! I am trying to figure out how to put echoed php results from mySQL database into a table ready for styling to look how i want it too. So far i have got to the point where the results are echoed out but they are not in a good table layout. (under "latest removalspace user's) I want it more structured in my table. I have found out how to create the table but just not been able to work out how to fit the echo's in without snytax errors??? the "new" table that i want to use is near the end of the script. Code: [Select] <?php // Make a MySQL Connection mysql_connect("***", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); // Retrieve all the data from the "example" table $result = mysql_query("SELECT company_name, location, postcode, basicpackage_description, premiumuser_description, upload FROM Companies") or die(mysql_error()); // store the records into $row array and loop through while ( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ) { // Print out the contents of the entry echo "Name:\r".$row['company_name']; echo "\r\rLocation:\r".$row['location']; echo "\r\rPostcode:\r".$row['postcode']; echo "\r\nBasic Users:\r".$row['basicpackage_description']; echo "\r\nPremium Users:\r".$row['premiumuser_description']; echo "\r\nlogo:\r".$row['upload']; echo "<img src=\"http://www.removalspace.com/images/COMPANIES" . $row['upload'] . "\" alt=\"logo\" />"; echo "<table> <tr><th>Comppany Name</th><th>Location</th><th>Postcode</th><th>Basic Members</th><th>Upgraded Users</th><th>Company Logo</th></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>"; } ?> This is more than a question than anything else: I am looking for a tutorial or something that will allow me to make tables with php and mysql for example what I need is: mysql data: table = links lid = 1 lname = Page 1 linkid = page.php lid = 2 lname = Page 2 linkid = page2.php etc and i am try to get it so if there is 2 pages then the table would do Page 1 Page 2 if 3 Page 1 Page 2 Page 3 so there are 2 lname(s)s per row and 1 in each column and it would keep building the table and rows as more lname(s) are added. Does anybody know where to find a tutorial on doing something like this. Thanks in advance Hi everyone... I have a thumbnail page that is putting out tables that are skewed and I am not able to use CSS properly because of that. Is there anyways I can change the PHP output? This is my code... I think the highlighted area is responsible for my tables? But it is mismatching the <tr> and <td> tags.... I really want it to show a structured table.. like <table> <tr> <td> </td> </tr> </table> // Thumbnail Listing else if( $cid && empty( $pid ) ) { $number_of_thumbs_in_row = 4; // If current page number, use it // if not, set one! if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } // Define the number of results per page $max_results = 400; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); $result = mysql_query(" SELECT photo_id , photo_caption , photo_filename , photo_category FROM gallery_photos WHERE photo_category='".addslashes($cid)."' LIMIT $from, $max_results "); $nr = mysql_num_rows( $result ); if( empty( $nr ) ) { $result_final = "\t<tr><td>No Photos found</td></tr>\n"; } else { while( $row = mysql_fetch_array( $result ) ) { $result_array[]= "<a href='viewgallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' class='img'/></a>"; } $result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" ); list($category_name) = mysql_fetch_array( $result ); mysql_free_result( $result ); $result_final = "<tr>\n\t<td> <span class='navlinks'><a href=viewgallery.php>Albums</a></span><font color=#ff0000> >> </font> <span class='navlinks'><a href=viewgallery.php?cid=$cid>$category_name</a></span><br><br/><br/><br/></td>\n</tr>\n"; foreach($result_array as $thumbnail_link) { if($counter == $number_of_thumbs_in_row) { $counter = 1; [b][size=24pt][size=18pt][b]$result_final .= "\n</tr>\n<tr>\n";[/b][/size][/size][/b] } else $counter++; [b][size=18pt] $result_final .= "\t<td>".$thumbnail_link."</td>\n";[/size][/b] } if($counter) { And my HTML output shows the tables like this... Code: [Select] <body> <table width='100%' border='0' align='center' style='width: 80%;'> <tr> <td> <span class='navlinks'><a href=viewgallery.php>Albums</a></span><font color=#ff0000> >> </font> <span class='navlinks'><a href=viewgallery.php?cid=1>Abstract</a></span><br><br/><br/><br/></td> </tr> <td><a href='viewgallery.php?cid=1&pid=240'><img src='photos/tb_240.jpg' border='0' alt='End Of Day' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=239'><img src='photos/tb_239.jpg' border='0' alt='A Photographer's Dream' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=238'><img src='photos/tb_238.jpg' border='0' alt='Heaven's View' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=237'><img src='photos/tb_237.jpg' border='0' alt='Colorful World ' class='img'/></a></td> </tr> <tr> <td><a href='viewgallery.php?cid=1&pid=241'><img src='photos/tb_241.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=242'><img src='photos/tb_242.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=243'><img src='photos/tb_243.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=244'><img src='photos/tb_244.jpg' border='0' alt='' class='img'/></a></td> </tr> <tr> <td><a href='viewgallery.php?cid=1&pid=245'><img src='photos/tb_245.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=246'><img src='photos/tb_246.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=247'><img src='photos/tb_247.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=248'><img src='photos/tb_248.jpg' border='0' alt='' class='img'/></a></td> </tr> <tr> <td><a href='viewgallery.php?cid=1&pid=249'><img src='photos/tb_249.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=250'><img src='photos/tb_250.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=251'><img src='photos/tb_251.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=252'><img src='photos/tb_252.jpg' border='0' alt='' class='img'/></a></td> </tr> <tr> <td><a href='viewgallery.php?cid=1&pid=253'><img src='photos/tb_253.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=254'><img src='photos/tb_254.jpg' border='0' alt='' class='img'/></a></td> <td><a href='viewgallery.php?cid=1&pid=255'><img src='photos/tb_255.jpg' border='0' alt='' class='img'/></a></td> </table> </body> hi everyone, Whats the best way to put my displayed php into my table? I already have gotten to the point where it is displayed, but it looks basic, so i want it to look like the table below it.... i just havent quite figured out how to "space" the data out so it looks better? Is it just a case of printing out what i want where in the table? or is it something more complex? http://www.removalspace.com/indextwo.php Hi guy's, i have 2 tables and in both i need to cheack some variable, and i don't know how! I tried with mysql_num_rows, but it need to have min one as value. i cheacked in first table and if the table dosn't have that in it, i need to try with other one, but i dont know how! i hope you understand what is the problem! I need to get the friends password and insert it into the table so the friend can delete it later can some one help me do a table join <?php //include the connect script include "../../../../connect.php"; //Post variables from flash $username = $_POST['username']; $password = $_POST['password']; $status = $_POST['status']; $friend = $_POST['friend']; $username = stripslashes($username); $password = stripslashes($password); $status = stripslashes($status); $friend = stripslashes($friend); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $status = mysql_real_escape_string($status); $friend = mysql_real_escape_string($friend); $sql = mysql_query("SELECT * FROM user_declined_list WHERE username = '$username' and password = '$password' and friend = '$friend' and status ='$status'"); $rows = mysql_num_rows($sql); $your_username=$rows['username']; if($rows > 0) { echo "&msgTextFriendShipRejected= RESEND NEW FRIEND REQUEST SUCCESSFULLY!"; // ok they are now our friend but we are not thier friend so lets insert the friendship in reverse and set the status to 1 on both ends // Problem i see is this if the user wishs to remove the friend later he will neen his password set to delete from this table. // so i need to do a join table again where friend password gets inserted here.. $insertnewfriend = mysql_query("INSERT INTO user_friends_list (username,password,friend,status) VALUES ('$friend','$password','$username','0')") or die(mysql_error()); //ok lets update the request and set the friend to be a friend becuase we said yes be my friend. $deleteuserfriend = mysql_query("DELETE FROM user_declined_list WHERE username = '$username' and password = '$password' and friend = '$friend' and status ='0'"); return; } ?> |