Jump to content

Search the Community

Showing results for tags 'table'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi guys, i have a db in mysql and a script in php gets data from the db and prints a table. The script is the following $connection = mysql_connect("localhost", "Litsa", "integratorgold"); echo $connection; mysql_select_db("mattrix"); $data = mysql_query("SELECT fNo, FieldA, FieldB FROM matin ORDER BY fNo DESC"); Print "<table border cellpadding=3>"; Print "<tr><th>No</th>"; Print "<th>Field A</th>"; Print "<th>Field B</th>"; Print "</tr>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td>".$info['fNo'] . "</td> "; Print "<td>".$info['FieldA'] . "</td> "; Print "<td>".$info['FieldB'] . "</td> "; Print "</tr>"; } Print "</table>"; Obviously, it's not my invention. The above code appears in many tutorials and although being a rookie i made it work. The file "pict-single.JPG" shows the output of the script. Nothing special, it works as expected. The file "pict-double.JPG" shows what i need to do. The $data variable contains the results of the query. It is an array containing the output records sorted as requested. The while part of the code navigates from the first record of the #data variable to the last.Is it possible to address a specific record in $data?
  2. Hi I want to make a table that has table rows like this: There are 3 horses in the sky. There are 4 cows in the stable. There are 5 dogs in the sea. The numbers, the animal names and the places have to be placed neatly below each other, so therefore I probably need to use the <td></td>. I tried using the printf ($format, $number, $animal, $place) function, and the array's $number=array(3,4,5); $place=array(sky,stable,sea); $animal=array(horses, cows, dogs); But I only get one tablerow that says (, There are, Array, Array, in the, Array); Can anyone please tell me what code I have to use to make this? Thanks already.
  3. Hi Just starting with php... This is the first part of the code: <?php $bestek = array ('vorken' => 5, 'messen' => 6, 'lepels' => 7); $servies = array ('borden' => 5, 'kopjes' => 6, 'schalen' => 2); $keuken = array ('bestek' => $bestek, 'servies' => $servies); echo '<table border=1>'; foreach ($bestek as $key => $value) { echo "<tr>"; echo "<td>". $key."</td>"."<td>".$value."</td>"."<br>\n"; echo "</tr>"; } foreach ($servies as $ke => $valu) { echo "<tr>"; echo "<td>". $ke."</td>"."<td>".$valu."</td>"."<br>\n"; echo "</tr>"; } echo "</table>"; ?> Printing the array's $bestek and $servies is not a problem, but now I want to print the $keuken-array in a table. Can anyone please help me with the code for that? I tried several things, but the result always is: Bestek Array Servies Array Thanks already for your help.
  4. mySQL version:5.5.24 I need help with the column type ENUM. What I want to happen is for this column to get either yes or no values. I think ENUM is used specifically for this but i dont know how to set up the column for this to work. I tried to just select ENUM as the type and leave everything else blank but when I save it gives me the error "This is not a number". I have other columns, but im almost sure the error is coming from the ENUM column. Please help.
  5. I am looking to alternate the row color on this loop I have. I have looked up a couple things through google, but none of them seem to fit into what I have. Let me know if this is simple or any suggestions on how to do this. Here is my code: $fields = array('RefNumber'=>'Reference Number','Status'=>'Status','Rep'=>'Rep','Disposition'=>'Disposition','appNumber'=>'appNumber', 'Con_Number'=>'Contract Number','Finance_Num'=>'Finance Number','Phone_Num'=>'Phone Number','Disc_Amount'=>'Discount Amount', 'Total_Cost'=>'Total Cost','Total_MP'=>'Total Monthly Payments','New_MP_Amt'=>'New MP Amount','New_DP_Amt'=>'New DP Amount','Notes'=>'Notes'); // start table and produce table heading echo "<table>\n<tr>"; $color1 = "#EFEFEF"; $color2 = "#FBFBFB"; foreach($fields as $legend){ echo "<th>$legend</th>"; } echo "</tr>\n"; // output table data while($row = sqlsrv_fetch_array( $result,SQLSRV_FETCH_ASSOC)) { echo "<tr>"; foreach($fields as $key=>$not_used) { echo "<td>$row[$key]</td>"; } echo "</tr>\n"; } echo "</table>\n"; $color1 & $color2 are the background colors I want to alternate on each row.
  6. Right now I have a code that outputs results into a table: <?php include 'includes/db_connect.php'; $List = $_GET['List']; if( $connection === false ) { echo "Unable to connect.</br>"; die( print_r( sqlsrv_errors(), true)); } $query = " SELECT LISTCODE, YEAR, COUNT(YEAR) AS Count FROM Names GROUP BY LISTCODE, RIGHT(LISTCODE, 2), YEAR HAVING (RIGHT(LISTCODE, 2) = '$List') ORDER BY LISTCODE, YEAR "; $result = sqlsrv_query($connection,$query); // each array key is the database column name, the corresponding value is the legend/heading to display in the HTML table // the order of the items in this array are the order they will be output in the HTML table $fields = array('LISTCODE'=>'ListCode','YEAR'=>'Year','Count'=>'Count'); // start table and produce table heading echo "<table>\n<tr>"; foreach($fields as $legend){ echo "<th>$legend</th>"; } echo "</tr>\n"; // output table data while($row = sqlsrv_fetch_array( $result,SQLSRV_FETCH_ASSOC)) { echo "<tr>"; foreach($fields as $key=>$not_used) { echo "<td>$row[$key]</td>"; } echo "</tr>\n"; } echo "</table>\n"; sqlsrv_free_stmt ($result); sqlsrv_close( $connection); ?> That all works great and the attached picture originalqueryoutput is what it looks like. Just a little hard to read. What I would like to is have the output look something like the attached picture wantedqueryoutput, which I just did in excel to show an example of what I am going for. Is this possible? And how would I even begin to manipulate the data rows from the query to the table? Thanks in advance for the help!
  7. Hi, I have just started to learn html and php. I have a webpage which retrieves a list of names from a table and adds them to a drop down list within a form. When a user selects a name and presses submit the name is then passed onto the the next php page which displays all the details. I wanted to make it a little more fancy and so changed the drop down list to a table. The question, is it possible to make the names or rows selectable so the program carries out the same task but instead the user selects a name in the table or a row? The table is dynamic as more users are added or deleted from the system. If any one could point me in the right direction please. Thanks Chris
  8. I have this code here and it works, just wondering if there is an easier and cleaner way to do this or not. Here is the code I have: <?php include 'includes/db_connectdate.php'; $Start_Date = $_GET['start_date']; $End_Date = $_GET['end_date']; $Forte_ID = $_GET['ForteID']; $query = ' SELECT Reps.Rep, Logs.RefNumber, Logs.Disposition, Logs.Cancel_Disposition, Logs.Date, Logs.appNumber, Logs.Phone_Num, Logs.Con_Number, Logs.Finance_Num, Logs.Num_Payments, Logs.ACH_CC, Logs.Post_Date, Logs.Callback, Logs.Disc_Amount, Logs.Total_Cost, Logs.Total_MP, Logs.New_MP_Amt, Logs.New_DP_Amt, Logs.Notes FROM Logs INNER JOIN Reps ON Logs.ForteID = Reps.ForteID WHERE Logs.Date BETWEEN \''.$Start_Date.'\' AND \''.$End_Date.'\' AND Logs.ForteID = \''.$Forte_ID.'\' ORDER BY Logs.RefNumber'; $result = sqlsrv_query($connection,$query); if (!$result) { $message = 'ERROR: ' . sqlsrv_errors(); return $message; } else { echo '<table border="1" cellpadding="5" style="border:3px solid black; text-align: center;"> <tr> <th style="border:3px solid black;">Rep</th> <th style="border:3px solid black;">Reference Number</th> <th style="border:3px solid black;">Call Disposition</th> <th style="border:3px solid black;">Cancel Disposition</th> <th style="border:3px solid black;">Date</th> <th style="border:3px solid black;">AppNumber</th> <th style="border:3px solid black;">Phone Number</th> <th style="border:3px solid black;">Contract Number</th> <th style="border:3px solid black;">Finance Number</th> <th style="border:3px solid black;"># of Payments</th> <th style="border:3px solid black;">ACH/CC</th> <th style="border:3px solid black;">Post Date</th> <th style="border:3px solid black;">Callback</th> <th style="border:3px solid black;">Discount Amount</th> <th style="border:3px solid black;">New Total Cost</th> <th style="border:3px solid black;">Total Monthly Payments</th> <th style="border:3px solid black;">New MP Amount</th> <th style="border:3px solid black;">New DP Amount</th> <th style="border:3px solid black;">Notes</th> </tr>'; while ( $row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ASSOC )) { echo '<tr style="border:3px solid black; text-align: center;">'; echo '<td nowrap>'.$row['Rep'].'</td>'; echo '<td nowrap>'.$row['RefNumber'].'</td>'; echo '<td nowrap>'.$row['Disposition'].'</td>'; echo '<td nowrap>'.$row['Cancel_Disposition'].'</td>'; echo '<td nowrap>'.$row['Date'].'</td>'; echo '<td nowrap>'.$row['appNumber'].'</td>'; echo '<td nowrap>'.$row['Phone_Num'].'</td>'; echo '<td nowrap>'.$row['Con_Number'].'</td>'; echo '<td nowrap>'.$row['Finance_Num'].'</td>'; echo '<td nowrap>'.$row['Num_Payments'].'</td>'; echo '<td nowrap>'.$row['ACH_CC'].'</td>'; echo '<td nowrap>'.$row['Post_Date'].'</td>'; echo '<td nowrap>'.$row['Callback'].'</td>'; echo '<td nowrap>'.$row['Disc_Amount'].'</td>'; echo '<td nowrap>'.$row['Total_Cost'].'</td>'; echo '<td nowrap>'.$row['Total_MP'].'</td>'; echo '<td nowrap>'.$row['New_MP_Amt'].'</td>'; echo '<td nowrap>'.$row['New_DP_Amt'].'</td>'; echo '<td nowrap>'.$row['Notes'].'</td>'; echo '</tr>'; } echo '</table>'; } sqlsrv_free_stmt ($result); sqlsrv_close( $connection); ?> Thanks for the help in advance!
  9. Im having a bit of trouble with my script. I wrote the script originaly to run from one variable which i changed manualy, but now im trying to put the whole script inside a loop. The script is now running all the way through fine on the first loop, starting starting the second but getting stuck at the part with my implode. This is my script that is around the implode area. Bear in mind that this code snippet is from a very large script. $t=1; while ($t <= $bm) { $mn=${'m'.$t}; $mn2[$t]="$mn"; $t++; } // The is where the script runs to, and the error comes from the next few lines and the script stops running $implode=implode(',', $mn2); print $implode; $query2="SELECT * FROM artists WHERE id IN(".implode(',', $mn2).")"; $result2=mysql_query($query2) or die(mysql_error()); $i=0; $bm2=$bm-1; while ($i <= $bm2) { $id3=mysql_result($result2,$i,"id"); ${"id3$i"} = $id3; $s1=mysql_result($result2,$i,"s1"); ${"s1$i"} = $s1; $s2=mysql_result($result2,$i,"s2"); ${"s2$i"} = $s2; $sl1=mysql_result($result2,$i,"sl1"); ${"sl1$i"} = $sl1; $sl2=mysql_result($result2,$i,"sl2"); ${"sl2$i"} = $sl2; $i++; } And this is the error that im getting ,,,You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,)' at line 1 Any help or point in the right direction would be amazing right no. Thanks Eric
  10. Hello, I have a table that I read in from a postgresql database but I need to add a column that has checkboxes in the final row. It is for a shop so then when the item is selected via checkbox I can then press an add to cart button and send this using an array to the cart.php page. Firstly I need to be able to add checkboxes to the end of each row before I can even do that and I am struggling at how to get a checkbox at the end of each row of my table. <form action="index.php" method="post"> <table> <tr> <th>ref</th> <th>title</th> <th>platform</th> <th>description</th> <th>price</th> <th>select</th> </tr> <?php $resource = pg_query ($connect, "select refnumber,title,platform,description,price from CSGames"); while ($row = pg_fetch_array ($resource)) { $result[] = $row; } foreach($result as $key => $value) { echo "<tr>"; for ($j = 0; $j < pg_num_fields ($resource); $j++) { echo "<td>".$a[$j]."</td>"; } echo "</tr>"; } ?> </table> Could any help with this and explain so I can understand what is occurring in the future please?
  11. Hi friend I try to create a simple html table and put on every cell data from three arrays my arrays are: $one = array('title1','title2','title3','title4','title5','title6'); $two = array('image1','image2','image3','image4','image5','image6'); $three = array('text1','text','text3','text4','text5','text6'); What i like to create is a table like this: ----------------------------------- | title1 | title2 | title3 | ----------------------------------- | image1 | image1 | image3 | ----------------------------------- | text1 | text2 | text3 | ----------------------------------- | title4 | title5 | title6 | ----------------------------------- | image4 | image5 | image6 | ----------------------------------- | text4 | text5 | text6 | ----------------------------------- In other words i need a script to create a rows take the first 3 data from every array put them on cells and every 3 cells create a new set of rows. Until now i'm able using the following cote to put data from only one array $numFiles = count($one); $start = 0; $end = $numFiles; $split = 3; print "<table><tr>"; for($i = $start; $i < $end; $i++) { print "<td>".$one[$i]."</td>"; if(($i) % ($split) == $split-1){ print "</tr><tr>"; } } print"</tr></table>"; If i use something like this: $numFiles = count($one); $start = 0; $end = $numFiles; $split = 3; print "<table><tr>"; for($i = $start; $i < $end; $i++) { print "<td>".$one[$i]."</td>"; if(($i) % ($split) == $split-1){ print "</tr><tr>"; for($i = $start; $i < $end; $i++) { print "<td>".$two[$i]."</td>"; if(($i) % ($split) == $split-1){ print "</tr><tr>"; } } } } print"</tr></table>"; I get this: ----------------------------------- | title1 | title2 | title3 | ----------------------------------- | image1 | image1 | image3 | ----------------------------------- | image4 | image5 | image6 | ----------------------------------- I know that i'm close but i need some help...
  12. Hello, I currently have a table that displays a list of elements from a shop. The information comes from a postgreSQL database and is then shown on index.php using a table. The problem I have is I need to add a checkbox to the end of each row so when I select multiple items I can add them to basket. I have the 'select' column set up but no checkboxes as of yet. I need to first implement the checkboxes and then from there I can get and post the selected items into the basket.php page. Any help would be massively appreciated. This is probably something simple im just overseeing. Would rather you also explain than try and give a straight up answer as I am more likely to learn that way. Thank you
  13. I'm attempting to set display some data pulled from the database and present it in a table so i can get everything to line up correctly. When I attempt to form a table around it, the content hops out of the table or part of it does not display. Working on the first row, it currently displays 'CITIZENSHIP: USA' //if ($citizenship) { echo "<strong>CITIZENSHIP:</strong> $citizenship"; If I try this, it displays 'USA', the citizenship 'vanishes'. //if ($citizenship) { echo "<tr> // <td align=\"right\" valign=\"top\"><p><strong>CITIZENSHIP:</strong></p></td> // <td width=\"10\"> </td> // <td valign=\"top\"><p>" . $citizenship . "</p> // </td></tr>"; <table cellpadding=\"0\" cellspacing=\"0\"> <?php //if ($citizenship) { echo "<tr> // <td align=\"right\" valign=\"top\"><p><strong>CITIZENSHIP:</strong></p></td> // <td width=\"10\"> </td> // <td valign=\"top\"><p>" . $citizenship . "</p> // </td></tr>"; if ($citizenship) { echo "<strong>CITIZENSHIP:</strong> $citizenship"; if ($legalstatus) { echo ", $legalstatus"; } echo "<br >\n"; } else if ($legalstatus) { echo "<strong>Legal Status:</strong> $legalstatus"; } // end legal status if ($type=="administrator" || $type=="alumni" || $type=="faculty" || $type=="staff" || $type=="student") { $theseFields = array("placeofbirth", "maritalstatus", "occupation", "affiliation"); } else { $theseFields = array("placeofbirth", "maritalstatus", "occupation", "affiliation", "baseofoperations"); } // end if resident foreach ($theseFields as $thisField) { if (${$thisField}) { echo "<strong>" . ${$thisField . "Name"} . ":</strong> "; echo ${$thisField}; if (isset(${"former" . $thisField})) { if (${"former" . $thisField}) { echo " (formerly " . ${"former" . $thisField} . ")"; } } // end if set } // end if info } // end FOREACH if ($type=="administrator" || $type=="alumni" || $type=="faculty" || $type=="staff" || $type=="student") { ?> </table> ANy help would be greatly appreciated. I'm very much a newb. Thanks to anyone kind enough to try to help me with this. I've been struggling with this all day and i really thought it'd tage a few minutes. Thanks
  14. Hey All, I always use Blue Host for my websites, but they don't let you use the CREATE TABLE MYSQL command. Does anyone know of any hosting services, reliable ones, that allow you to use this command?? And on a side note, best free web hosting?? Thanks in advance,
  15. MYSQL version --> 5.0.91 ALTER TABLE products ENGINE=INNODB; The error is that it responds that it changed the engine type, but when I view the database in mysqladmin, the tables are still MYISAM. I really wish I saved the CREATE TABLE commands. Basically, there are three tables. The variable types are VARCHAR, INT, TINYINT, DECIMAL, DATETIME, and YEAR. There are no null fields. One of the tables is a JOIN table, and all three of them possess foreign keys. Please let me know if I left out anything, and thank you in advance for your consideration. I threw together a couple of screen shots. Above the red line shows my command and the response showing that I successfully changed the sessions table. Below the red line shows what I see when I view the database in mysqladmin; the sessions table still has a MYISAM engine type.
  16. Can anyone provide their method of getting the results to show as a table as the results it showing now is an unreadable mess, I'd also like the following css styling as follows: Padding: 20px Border: 1px solid grey th to be in light grey Id be greatfull if someone could put the code into a table as its driving me nuts lol Here is the code for showing the results: $sql = "SELECT animal_type, animal_breed, colour, owner_name, address, telephone, mobile, email, offence, offence_date, offence_location, case_status, case_ref, action_required, action_taken, microchipped, microchip_number, aggressive, dangerous, lost, date_lost, location_lost, stolen, date_stolen, location_stolen, found, date_found, location_found, other_information FROM `animals` WHERE 1"; $result = $conn->query($sql); if ($result->num_rows > 0){ while($row = $result->fetch_assoc() ){ echo $row["animal_type"]." ".$row["animal_breed"]." ".$row["colour"]." ".$row["owner_name"]." ".$row["address"]." ".$row["mobile"]." ".$row["email"]." ".$row["offence"]." ".$row["offence_date"]." ".$row["offence_location"]." ".$row["case_status"]." ".$row["case_ref"]." ".$row["action_required"]." ".$row["action_taken"]." ".$row["microchipped"]." ".$row["microchip_number"]." ".$row["aggressive"]." ".$row["dangerous"]." ".$row["lost"]." ".$row["date_lost"]." ".$row["location_lost"]." ".$row["stolen"]." ".$row["date_stolen"]." ".$row["location_stolen"]." ".$row["found"]." ".$row["date_found"]." ".$row["location_found"]." ".$row["other_information"]."<br>"; } } else { echo "0 records"; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.