Search the Community
Showing results for tags 'loop'.
-
I have a questions table and feedback table. I able to foreach the question header but not the feedback. My code as above: <?php $sql2 = "SELECT DISTINCT[question_id],[q_text] FROM [question]"; $ques = array(); $stmt2 = sqlsrv_query($conn, $sql2, $ques); while ($row = sqlsrv_fetch...
-
Get Image by number, but if loop when no image? Help
Rowena_Harris posted a topic in PHP Coding Help
Hi - can anyone help? I'm new to PHP land, and failing at this particular part. I have an image slider - where each image is contained in a div (e.g it is not a slider using ul and il...) It is will be used in a template for many pages, which will each have a varying number of images....- 2 replies
-
- get image
- image slider
-
(and 1 more)
Tagged with:
-
<?php function factorial($number) { if ($number < 2) { return 1; } else { return ($number * factorial($number-1)); } } function poisson($occurrence,$chance) { $e = exp(1); $a = pow($e, (-1 * $chance)); $b = pow($chance,$occurrence); $c = factorial($occurrence); return $a * $b / $c; } $x = 2.5; $...
-
Here's a line. I want to add 100 more of same lines and increment the page numbers as shown below. I know I can just manually add 100 lines but Is there a way to do this with PHP that would make it easy? Or is this more of a javascript thing? // original $page1 = '<a href="?type='. $type_id .'&...
-
Is it possible to append to cdatasection within xml file using a loop without creating a new cdata section with each loop thru. The code starts out by creating the basics for xml then enters into a loop to go thru each element of an array, appending the cdata. $xml=new DOMDocument('1.0', 'UTF-8');...
-
Hi, guys i'm trying to fetch all results from DB through a foreach loop. But it is not working as intended, as it brings only the first record and not the others. here is my code:- $sql1="select * from group_posts"; $stmt_t=$conn->prepare($sql1); $stmt_t->execute(); $data_fetch=$stmt_t->fetchAll(...
-
Hello. Just a quick question about using a loop to create a string from post variables that will then be used in a query. I have several post variables submitted in a form, some of which contain a value of T. Others are not selected. In the database there are several columns which may contain va...
-
Hi, I am having a small issue with a front end html form, which through a series of looped input fields will update multiple WordPress posts at once, on submisson. The issue i'm having currently, is on submission it's only updating 1 post. I have found a solution to my problem, here: htt...
-
I have the following in a form that edits values already put into a dbase. $alev = array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => 'AP'); $dblev = explode(',',$row['hw_lev']); foreach ($alev as $key => $lev){ if(in_array($lev,$dblev)){ echo "<input type='checkbox' name='ud_lev[]'...
-
Hi all, I am trying to calculate the straight line distance between two points by using their co-ordinates on each row from a mysql db that satisfies the query. It works fine, except the last for loop below calculates $lat[$x+1],$long[$x+1] to have blank fields as they no longer exist in the...
-
Say I have this loop. foreach($record as $row) { <div class="hello">Hello World!</div> } I want to loop through and add a letter alongside the "Hello World!" above. To do that, I found this code. $azRange = range('A', 'Z'); foreach ($azRange as $letter) { print("$letter\n"); } How can I...
-
This is my database structure: http://www.awesomescreenshot.com/image/733881/57d01b042ca99b9a36dde90dd6640cdc I would like to loop through all the child elements (those who's parent_id is set to the data_id within the same table). Therefore those with "parent_id" as "0" are parents, and tho...
-
Hello - I hope I explain this clearly... I have some php code that presently displays 4 boxes in a row with images. When you click on a box/image, you go to a web post. The code goes to the bottom, sets the link, then loops back for the next image and repeats the process. What I'm trying...
-
Hi, I am trying to add values together in my while loop, so far I have: $q->query($DB, $SQL); while($avrating=$q->getrow()): $averageratings = $avrating['sum(rating)'] / $noofreviews; $overallaverage = round($averageratings, 2) + round($averageratings, 2); echo '<p>'.$avrating['rating_name...
-
Hi, I have 2 tables of data REVIEWS and RATINGS I would like to show a list of my reviews and a list of rating for each of my reviews I have tried putting my second WHILE loop inside teh first one but that doesn't work, can anyone please help? here is my code: $SQL = "SELECT...
-
Hello so I have a simple code here that will check if a random number already exists in the database and will generate a new one: $rand = mt_rand(100000, 999999); $sid = array( ":sponsorID" => $rand ); $accounts = $db->select("accounts", "sponsorID = :sponsorID", $sid) while(count($accounts) >...
-
Hi I'm currently connecting to a API to retrieve info. The info I'm retrieving is in the form of Std Class Object. The problem I'm experiencing is that the results I get from one call is limited to 25. They say I should iterate it. But im not sure how to do so. My code so far <html> <?php req...
-
First off, I am very new to php and I am learning the best I can. I am trying to display a dynamic grid style table within a loop and display my mysql data inside of it. The data is a Image URL, directory URL, URL description, and it prints all this data as an image with a link to the gallery. T...
-
I am having a bit of issue. I have a simple query that loops to find each record, like this. // select query here if(count($result) > 0) { foreach($result as $row) { $userid = $row['user_id']; $_SESSION['userid'] = $userid; } } else { // error here } I want to use th...
-
How come this doesn't loop? Everything is in the while loop. My database connection is in the included file you see to begin the code which is what db_conx refers to just to be clear. Database connection is not an issue nor is getting values. I just get the first one and nothing more. No loopin...
-
Hi everyone, greetings from Brazil. I am an average php coder, much more a designer than an programer, and i am in a looper trouble.. Can anyone try to help me? Here is my code: <table border="1"> <tr> <?php //pega cada uma das operadoras do campo op...
-
Hi guys, Having trouble trying to show values from my $friend array. Only the first friend code is being displayed in my output. There are several fields in my mysql associated with the $sql. Any ideas? Thanks $sql = "SELECT * FROM friends WHERE Code = '$code' OR FriendCode = '$code...
-
I need my user to log in to use their "admin panel" functions. I have this bit of html for them to enter their username/password: <form id="form1" name="form1" method="post" action="functions/loginprocess.php"> <table> <tr> </tr> <tr> <td>Username:</td> <td><input ty...
-
Greetings all, I have been developing a comment box for my site and I ran into an issue I can't seem to figure out. In my comment box when I am logged in as an admin I want to be able to delete comments by simply clicking a button. The comments are printed out from a database using a while loop:...