PHP - Foreach Problem
Hello all,
I had some kind of same problem before and I made very hard changes on the project for that to work, but now I'm experiecing a sort of same problem and I can't change it at all so deep. I have group of number in an array that I explode: array($numbers = explode("|", $rest)); Than I "foreach it": foreach ($numbers as $n=>$num){ $sqlname = mysql_query("select name from table where number = '{$num}'"); $name = mysql_fetch_row($sqlname); echo $num." - ".$name[0]; } The result is: 51.399.517 - Danilo Piva Junior 57.716.524 - 02.067.142 - 51.629.749 - 51.109.841 - 59.852.855 - As it can be seen, the foreach returns each number ($num) holded on the array correctly, but when it need query a value from database it only returns the first value, it does not return each name ($name[0]) as expected. Please Thankx Danilo Jr. Similar TutorialsHi there, im having bit of a problem with this foreach.... as far as i can see i think its right? no doubt something is horribly wrong... lol. anyone have any idea? (post email would be for example "blah@blah.com, blah@blah.com2") ((which makes sense since this SHUD be arrayable???)) Code: [Select] <?php $emails = preg_replace("[^a-z0-9\@\.\_\-]", "", $_POST["email"]); $emailArray = explode(",",$emails); foreach($emailArray As $emails[0]){ $query = "SELECT count(email) FROM buddyp WHERE email='$emails[0]'"; $result = mysql_query($query) or die("Error: ".mysql_error()); $emailc = mysql_fetch_array($result, MYSQL_NUM); if ($emailc[0] == 0) { $query = "INSERT INTO buddyp SET email='$emails[0]',day='".time()."'"; mysql_query($query) or die("Error: ".mysql_error()); // message $message = 'EMAIL CONTENTS'; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: Ambroid <noreply@ambroid.co.uk>' . "\r\n"; // Mail it mail($emails[0], "AMBROID - The War Game", $message, $headers); $exc = "Emails were sent to: $emails[0]"; } else { $exc = "ERROR: You cannot invite the same person to the game within a 3 day period!"; } } ?> Hi! I have a problem when echoing some lines of an exploded string. The output of the code is: * [EMPRY LINE] * line with some writing #1 * line with some writing #2 * line with some writing #3 etc. I don't get why the first (empty) line is included.. Code: [Select] <?php $lines = explode('-', $text); foreach($lines as $line) { echo '*', $line, "<br />"; } ?> any help is appreciated! I am trying to make a basic navigation across the top of my pages in my navmenu showing all of the categories in my ob_category table. so if i add a category to the database later, the link in the navmenu is automatically added. this is what i was experimenting with at the moment: <?php $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query1 = "SELECT * FROM ob_category"; $data1 = mysqli_query($dbc, $query1); $row1 = mysqli_fetch_array($data1); foreach($row1['name'] as $value){ echo '<a href="viewlistings.php">' . $value . '</a> •'; } ?> not working, I'm not worried about the links working quite yet, its the category names im most concerned about any ideas?? I am new to this forum and I intend to become involved in its day-to-day exertions by helping and contributing in any way I can.
Now, despite the fact that I have programmed with PHP on and off for about 4 years and consider myself to be 'competent' in working with it, I have come across a problem that I can not understand or, therefore, solve. To give some context, I am creating a webpage or a pair of applications, for personal use, for the Telegraph Dream Team (after leaving the Sun for a reason that should be apparent to those who have used it). Firstly, I used Java to extract information from the website and put it into a PHPMyAdmin database. Then, I used the information, in this case, to allow people to submit teams using drop-down boxes, and here lies the problem.
I have used a foreach to display all of the 'keepers' and 'defenders' from the database as an option in the drop-down box, which works fine. However, the page only prints out every second drop-down box. For example, it will show the keeper(p1) selection box and then, in this case if a 442 formation is chosen, it will only print the third(p3) and fifth(p5) drop down boxes, namely it only prints every second drop-down menu. I am wondering what is causing this to happen. Is it a known problem with the overuse of the foreach and, therefore, should be avoided or is it something I have done wrong that causes the page to only print every second drop-down menu?
Sorry about the misaligned format of the code on the forum. Any information on what is causing this and any help on how to solve it would be greatly appreciated, thank you.
elseif (isset($_SESSION['formation']) and isset($_SESSION['teamname'])) { print " <form method='post' action='createteam.php'>"; print "Keeper: <select name='p1'> <option value='none'>Pick a Keeper</option>"; foreach ($k_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; if ($_SESSION['formation'] == '442' or $_SESSION['formation'] == '433' or $_SESSION['formation'] == '451') { print "Defender: <select name='p2'> <option value='none'>Pick a Defender2</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print "Defender: <select name='p3'> <option value='none'>Pick a Defender3</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print "Defender: <select name='p4'> <option value='none'>Pick a Defender4</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print "Defender: <select name='p5'> <option value='none'>Pick a Defender5</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print $_SESSION['formation']; } elseif ($_SESSION['formation'] == '352' or $_SESSION['formation'] == '343') { print "Defender: <select name='p2'> <option value='none'>Pick a Defender2</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print "Defender: <select name='p3'> <option value='none'>Pick a Defender3</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print "Defender: <select name='p4'> <option value='none'>Pick a Defender4</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print $_SESSION['formation']; } elseif ($_SESSION['formation'] == '532') { print "Defender: <select name='p2'> <option value='none'>Pick a Defender2</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print "Defender: <select name='p3'> <option value='none'>Pick a Defender3</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print "Defender: <select name='p4'> <option value='none'>Pick a Defender4</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print "Defender: <select name='p5'> <option value='none'>Pick a Defender5</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print "Defender: <select name='p6'> <option value='none'>Pick a Defender6</option>"; foreach ($d_array as $option) : print "<option value=$option->name'> {$option->name} ({$option->value}) </option>"; endforeach; print $_SESSION['formation']; } else { print "You have not picked a formation!"; } print "</br> <input type='submit' value='Submit your team'> </form>"; } hi all, im still new with php, any my english are messed up so be patience anyway i have a code like this Code: [Select] if ($Stop == "0") { foreach ($bot->fobjects as $obj) { if (($obj["className"] == "Home")) { echo "Running"; break; } else { echo "Not Running"; break; } } } the problem is, its not running the way it suppose to, as it always go to the else section even if there is an array with className Home inside the $bot->fobjects and when i do the obj var_dump below the echo "Not Running"; it always show the wrong array and the strange thing if i remove the else section, the code is working good and it show the correct array is there something wrong with my code? thank you Hi all, I have a lot of images in a directory called image1.jpg image1_thumb.jpg image2.jpg etc.. When I use this code foreach (glob('./aircraft/' . $_GET['reg'] . '*.jpg') as $file) The foreach statement gets the _thumb.jpg images - I am trying to just get the images without _thumb.jpg at the end. What is wrong with it? I am guessing it is the *.jpg but I have tried taking that out and the script then does not work. Thanks for your help. Hello to all I have problem a with my foreach loop.. First : Is it possible to rename each element that's been outputted everytime the loop execute? Code: [Select] <?php $arr = array(mikel, 17, cambodia, 50kgs, 5 feet, anna, 21, peru, 45kgs, 6 feet); foreach ($arr as &$value) { $value = $value; } ?> What i would like on the result of the foreach loop is name : mikel Age : 17 address : cambodia weight : 50kgs height : 5 feet is this possible? Second : i want to echo the result of the for each loop in every 5 turns. result 1 = mikel, 17, cambodia, 50kgs, 5 feet result 2 = anna, 21, peru, 45kgs, 6 feet Can anyone help me on this? thanks Hello. I was wondering if anyone could please help with a problem I seem to be having a problem with my foreach loops. I have an array that holds other arrays. When I am trying to populate the database tables with the information in each array, things are going horribly wrong. This is my code: $tabledata = $this->db->get('tableinfo'); $i = 0; $_temp = array(); foreach($tabledata->result() as $row) { $data[$i] = $this->callAPI("lateststandings&records=3&category=" . $row->category . "&distance=" . $row->distance_id); array_push($_temp, $row->dbname); $i++; } $j = 0; foreach($data[$j]['Records']['Record'] as $record) { $record['FirstName'] .= " " . $record['LastName']; $this->db->replace($_temp[$j], $record); $j++; }
When this is run 2 things are happening:
1) What I am expecting to happen is, there should be 3 rows added to each table. But only 1 is being added to each table. I am not sure what I am doing wrong in these loops.
Hiya! I have an issue, here is my code. <?php class generateInvoice { private $invoiceID; public function __construct($invoiceID) { $this->_INID = mysql_real_escape_string($invoiceID); } public function __drawInvoice() { $get_invoice = "SELECT * FROM `invoices` WHERE `id` = '$this->_INID' LIMIT 1"; $run_get_invoice = mysql_query($get_invoice); if($run_get_invoice) { if(mysql_num_rows($run_get_invoice) == 1) { while($invoice_m = mysql_fetch_assoc($run_get_invoice)) { if($invoice_m == 1) { $status = 'Awaiting Payment'; } elseif($invoice_m == 2) { $status = 'Paid'; } $items_mass = explode(',', $invoice_m['items']); foreach($items_mass as $item_key => $item_value) { $item_split = explode('-', $item_value); echo '<pre>' . print_r($item_split, true) . '</pre>'; foreach($item_split as $item_key_final => $item_value_final) { $invoice .= ' <tr class="item-row"> <td class="item-name"><div class="delete-wpr">' . $item_value_final[1] . '</div></td> <td class="description">THIS IS THE DESCRIPTION</td> <td><span class="cost">$650.00</span></td> <td><span class="qty">1</span></td> <td><span class="price">$650.00</span></td> </tr>'; } } } return $invoice; } else { return false; } } else { return false; } } } ?> This is what is displayed. Array ( => 1 [1] => Test Product [2] => 6.99 [3] => 2 ) Array ( => 5 [1] => Tester Product [2] => 600.99 [3] => 1 ) THIS IS THE DESCRIPTION $650.00 1 $650.00 e THIS IS THE DESCRIPTION $650.00 1 $650.00 . THIS IS THE DESCRIPTION $650.00 1 $650.00 THIS IS THE DESCRIPTION $650.00 1 $650.00 THIS IS THE DESCRIPTION $650.00 1 $650.00 e THIS IS THE DESCRIPTION $650.00 1 $650.00 0 THIS IS THE DESCRIPTION $650.00 1 $650.00 THIS IS THE DESCRIPTION $650.00 1 $650.00 I need it so that I can use each of the array's above and echo out each item (key) individually. I don't understand whats going wrong? Many thanks, James. I wonder whether someone can help me please. I've put together the script below, which allows users to view their saved images in the original folder structure that they were saved in. Code: [Select] <?php session_start(); $_SESSION['username']=$_POST['username']; $_SESSION['locationid']=$_POST['locationid']; ?> <!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"> <?php $galleryPath = 'UploadedFiles/' . $_SESSION['username'] . '/' . $_SESSION['locationid'] . '/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); $items = array(); for ($i = 0; $i < $descriptions->documentElement->childNodes->length; $i++) { $xmlFile = $descriptions->documentElement->childNodes->item($i); $path = $xmlFile->getAttribute('name'); $path = explode('/', $path); $t = &$items; for ($j = 0; $j < count($path); $j++) { if (empty($t[$path[$j]])) { $t[$path[$j]] = array(); } $t = &$t[$path[$j]]; } $t['/src/'] = $xmlFile->getAttribute('source'); $t['description'] = $xmlFile->getAttribute('description'); $t['size'] = $xmlFile->getAttribute('size'); } $basePath = empty($_GET['path']) ? '' : $_GET['path']; if ($basePath) { $basePath = explode('/', $basePath); for ($j = 0; $j < count($basePath); $j++) { $items = &$items[$basePath[$j]]; } } $files = array(); $dirs = array(); function urlpartencode(&$item, $index) { $item = rawurlencode($item); } foreach ($items as $key => $value) { if (isset($value['/src/'])) { $value['/src/'] = explode('/', $value['/src/']); array_walk($value['/src/'], 'urlpartencode'); $value['/src/'] = implode('/', $value['/src/']); $files[] = array( 'name' => $key, 'src' => $value['/src/'], 'description' => htmlentities($value['description'], ENT_COMPAT, 'UTF-8'), 'size' => htmlentities($value['size'], ENT_COMPAT, 'UTF-8') ); } else { $dirs[] = $key; } } $basePath = empty($_GET['path']) ? '' : $_GET['path']; $up = dirname($basePath); if ($up == '.') { $up = ''; } sort($files); sort($dirs); ?> <head> <title>View Image Folders</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="Styles/style.css" rel="stylesheet" type="text/css" /> <script src="Libraries/jquery/jquery-1.4.3.min.js" type="text/javascript"></script> <style type="text/css"> <!-- .style1 { font-size: 14px; margin-top: 5px; margin-right: -50px; } --> </style> <body style="font-family: Calibri; color: #505050; margin-right: 160px; margin-left: -180px;"> <div align="right" class="style1"> <a href = "index.php" /> Add Images <a/> → <a href = "javascript:document.imagefolders.submit()"> View All Images </a> </div> <form id="imagefolders" name="imagefolders" class="page" action="gallery.php" method="post"> <div id="container"> </div> <div id="center"> <div class="aB"> <div class="aB-B"> <?php if ('Uploaded files' != $current['title']) :?> <?php endif;?> <div class="demo"> <input name="username" type="hidden" id="username" value="IRHM73" /> <input name="locationid" type="hidden" id="locationid" value="1" /> <div class="inner"> <div class="container"> <div class="gallery"> <table class="gallery-link-table" cellpadding="0" cellspacing="0"> <thead> <tr class="head"> <th class="col-name"> Name </th> <th class="col-size"> Size </th> <th class="col-description"> Description </th> </tr> </thead> <tbody> <tr class="directory odd"> <td class="col-name"> <a href="?path=<?php echo rawurlencode($up); ?>">..</a> </td> <td class="col-size"> </td> <td class="col-description"> </td> </tr> <?php $i = 1; ?> <?php foreach ($dirs as $dir) : ?> <tr class="directory <?php $i++; echo ($i % 2 == 0 ? 'even' : 'odd'); ?>"> <td><a href="?path=<?php echo rawurlencode(($basePath ? $basePath . '/' : '') . $dir); ?>"><?php echo htmlentities($dir, ENT_COMPAT, 'UTF-8'); ?></a></td> <td>Folder</td> <td></td> </tr> <?php endforeach; ?> <?php foreach ($files as $file) : ?> <tr class="<?php $i++; echo ($i % 2 == 0 ? 'even' : 'odd'); ?>"> <td><a target="_blank" href="<?php echo $galleryPath . $file['src']; ?>"><?php echo htmlentities($file['name'], ENT_COMPAT, 'UTF-8'); ?></a></td> <td><?php echo htmlentities($file['size'], ENT_COMPAT, 'UTF-8'); ?></td> <td><?php echo htmlentities($file['description'], ENT_COMPAT, 'UTF-8'); ?></td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> </div> </div> </div> </div> </div> </form> </body> </html> I can create the list of correct folders for the user and location, but when I click the folder name to drill down to the indvidual images I receive the following error: Quote Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "/homepages/2/d333603417/htdocs/development/UploadedFiles/files.xml" in /homepages/2/d333603417/htdocs/development/imagefolders.php on line 17 Warning: Invalid argument supplied for foreach() in /homepages/2/d333603417/htdocs/development/imagefolders.php on line 54 Line 17 is this line: Quote $descriptions->load($absGalleryPath . 'files.xml') and line 54 is: Quote foreach ($items as $key => $value) { I know that in their own right, the piece of code which loads 'files.xml' and the code which loads the folders and images work, but it's combining them that creates the issue. I've done some research online, and I think the issue is to do with 'Session' variables and the 'foreach' array, but I'm not sure how to solve the problem. I just wondered whether someone could perhaps have a look at this please and let me know where I'm going wrong. Many thanks and regards I have the following code which works (thanks to PHP Freaks members)
foreach ($swap["sims"] as $swap) { echo $swap['voice'] . "</br>"; }But I can't figure out why the following doesn't work <select name="sim_for_swap[]"> <?php foreach ($swap["sims"] as $swap) { ?> <option value="<?php echo $swap['voice'];?>"><?php echo $swap['voice'];?></option> <?php } ?> Hi guys. So I have a little coding down but I am stuck on this problem: /* Using only a array and a foreach loop, write a program that prints the days of the week *\ $days = array { 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', }; //This is where I need help with the code echo "$day \r\n"; ?> Thanks in advance! Hi... I tried to use foreach in displaying my table header, but I encountered problem when I tried to display data on the first row , my query only display the last Sum for the last Comp. here is my code: <html> <head> <title>Half Shell</title> <link rel="stylesheet" type="text/css" href="kanban.css" /> <?php error_reporting(E_ALL ^ E_NOTICE); date_default_timezone_set("Asia/Singapore"); //set the time zone $con = mysql_connect('localhost', 'root',''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); ?> <body> <form name="param" action="" method="post" onSubmit="return false"> <div id="fieldset_PS"> <?php echo "<table>"; $sql = "SELECT DISTINCT s.Comp FROM sales_order s, param_settings p WHERE s.Comp = p.Compounds ORDER BY s.Comp"; $res_comp = mysql_query($sql, $con); while($row_comp = mysql_fetch_assoc($res_comp)){ $Comp[] = $row_comp['Comp']; } echo "<th> </th>"; foreach($Comp AS $Comp){ echo "<th>$Comp</th>"; } echo "<tr> <td>Total Kg/Compound</td>"; $sql_sec = "SELECT SUM(TotalKg) AS TotalKg FROM sales_order WHERE Comp = '$Comp' ORDER BY Comp"; $res_sec = mysql_query($sql_sec, $con); while($row_sec = mysql_fetch_assoc($res_sec)){ $TotalKg[] = $row_sec['TotalKg']; } foreach($TotalKg AS $TotalKg){ echo "<td>$TotalKg</td> </tr>"; } ?> I also attach the correct output that should be and the result from my code. Thank you hey guys, I'm quite new to PHP and i was wondering if someone would be able to help me out with this. The code i have checks the database to see if a user has provided a Vimeo ID. If they haven't, $video_check will equal a line of html that says the user hasn't added any videos to their portfolio. If the a vimeo ID is present, i want $video_check to equal a bunch of html and css with a foreach function inside that is used to display the users videos from vimeo. The foreach function works fine when its not assigned to the $video_check variable. How do i structure it so that it displays correctly? If you click on videos on this page you might get a better idea of what i'm talking about. http://www.myfilmportfolio.ie/profile.php?id=33 and here is the code i'm having the problem with: /////// check if user has provided vimeo id ////////////////////////// $vimeoID = $row["vimeoID"]; $video_check=''; if (empty($vimeoID)){ $video_check = '<h3>'.$firstname .' has not added any videos to their portfolio</h3>'; } else{ $video_check = '<div id="stats"> <div style="clear: both;"></div> </div> <div id="wrapper"> <div id="embed"></div> <div id="thumbs"> <ul> <?php foreach ($videos->video as $video): ?> <li> <h4><?=$video->title?></h4> <a href="<?php echo $video->url ?>"> <img src="<?php echo $video->thumbnail_medium ?>" class="thumb" /></a> <p><?=$video->description?></p> <br /> </li> <?php endforeach ?> </ul> </div> </div>'; } if anyone could help me out id really appreciate it. Cheers, G This topic has been moved to Application Frameworks. http://www.phpfreaks.com/forums/index.php?topic=355772.0 I'm not sure if the title explains it very well, but here is an image of it. I am trying to figure out how to access the option selected (equal, not equal, etc.), along with its input box, for each column (the checkboxes on the right) selected. The purpose of this is to allow a non-programming administrator user to create a custom query to access information. I can find out which checkboxes are selected no problem, but finding the accompanying drop-down option and input box is difficult for me. How do I do this? If you have a suggestion on how to change it, I'm very open. Thank you in advance! Code: [Select] if(!isset($_POST['submit'])) { echo " <form method='post'> <table> <tr> <td valign='top'>SELECT</td> <td valign='top'> <table>"; // LIST ALL COLUMNS IN A TABLE $result = mysql_query("SELECT * FROM table_name") or die(mysql_error()); $rowcount=mysql_num_rows($result); $y=mysql_num_fields($result); for ($x=0; $x<$y; $x++) { echo " <tr> <td> <input type='checkbox' name='fields[]' value='".mysql_field_name($result, $x)."'>".mysql_field_name($result, $x)." </td> </tr>"; } echo " </table> </td> <td valign='top'>FROM allocations</td> <td valign='top'>WHERE</td> <td> <table>"; // LIST ALL COLUMNS IN A TABLE $result = mysql_query("SELECT * FROM table_name") or die(mysql_error()); $rowcount=mysql_num_rows($result); $y=mysql_num_fields($result); for ($x=0; $x<$y; $x++) { echo " <tr> <td> <input type='checkbox' name='column[]' value='".mysql_field_name($result, $x)."'>".mysql_field_name($result, $x)." </td> <td> <select name='operator[]'> <option value='='>equals</option> <option value='<>'>does not equal</option> <option value='>'>greater than</option> <option value='<'>less than</option> <option value='>='>greater than or equal to</option> <option value='<='>less than or equal to</option> <option value='LIKE'>is like</option> </select> </td> <td><input type='text' name='criteria[]'></td> </tr>"; } echo " </table> </td> <td valign='top'><input type='submit' value='Process Query' name='submit' class='submit'></td> </tr> </table> </form>"; } else { echo "<b>Fields to edit:</b> "; foreach ($_POST['fields'] as $fields) { echo $fields,", "; } echo "<br><br>"; echo "<b>Columns to query:</b> "; foreach ($_POST['column'] as $columns) { echo $columns," HERE IS THE SPOT, "; } } Hi! When I echo $m below, it will show all selected options fine. Instead, I want it to show many I selected. So if I selected 3 in dropdown, I want it to say I selected 3 instead of showing their values. $allmaps=$_POST['maps']; foreach ($allmaps as $m) { echo 'm = '.$m.''; } <select name="maps[]" multiple>'.$maps.'</select> I appear to be having a simple simon day! my foreach is only displaying the last result in the table as opposed to each row $num_rows = mysql_num_rows($query); echo "There are $num_rows records.<br>"; while($row = mysql_fetch_row($query)) foreach ($row as $field) { echo '<div class="results">'; echo $field; echo '<br></div>'; } And the source Code: [Select] <link href="../styles/clientbox.css" rel="stylesheet" type="text/css"> <body><br> <h3>My Services</h3> <div class="text"> You currently have the following services with us: </div> There are 2 records.<br><div class="results">test1<br></div> </body> </html> My table has 2 rows which the 1st one has a package of test and the second a package of test1 Can anyone help? Thanks i have a table that echos 10 entries what i want to do is once it echos 5 records it starts a new table. I dont know how to go about this. Could you guys guide me the right way. In the code I want to proceed to the next step only after stripslashes and strip_tags are completed. How do I put the code below with if? $stripped = array('name', 'location', 'bio'); foreach ( $_POST as $k => $v ) { if ( in_array($k, $stripped) ) { ${$k} = strip_tags($v); } } foreach ( $_POST as $p => $q ) { if ( in_array($p, $stripped) ) { ${$p} = stripslashes($q); } } Thanks, Ruth. |