Tagged Questions
0
votes
2answers
29 views
SQL being executed twice in FOR loop
I think I need a second pair of eyes on this one. For the life of me I can't figure out why my SQL INSERT query is running twice every iteration:
if (($handle = fopen($spreadsheet_url, "r")) !== ...
0
votes
0answers
18 views
Set based query to insert multiple records in a new table for each record in the parent table. MySQL
Imagine I have to insert a number of records in a new table for each record in an old table.
As a (hopefully not over-) simplified example I have a table containing linestrings of variable lengths ...
-2
votes
0answers
18 views
mysql query that inserts and gives id of inserted record
I am looking for sql query that inserts a record and returns autogenerated id of that particular record.
And all should happen in single query without using last_inserted_id.
0
votes
2answers
29 views
Getting random array from a while loop in PHP
I have a page set up for testimonials for a company website. Just the standard message first name, last name, message, blah blah..anyways I can pull the message up and have a single entry show up ...
0
votes
1answer
34 views
While loops duplicating the results
I have 2 rows in the table and when I do a while loop to fetch it in the php it duplicates the results 5 times. As you can see it creates a table and there are just 2 rows it seems strange to ...
0
votes
3answers
47 views
INNER JOIN returning un-expected NULL (PHP/MySQL)
I am currently running a function which uses an inner join in a while loop which is un-expectedly returning nothing back.
$data3 = '\'' . implode('\', \'', $posted_email) . '\'';
$exam_recordation ...
1
vote
4answers
53 views
PHP while returns same result repeatedly
When running a while script on my local xampp it just returns the same result over and over again, here's the PHP I'm using:
<?php
$id = $_GET['id'];
$getmembers = mysql_query("SELECT * FROM ...
0
votes
1answer
36 views
Looping through function until condition is met
I'm trying to build a php function that checks if a certain url exists in the database:
$sql = "SELECT * FROM taskProposals WHERE url='$string'";
$query = mysql_query($sql);
$quantity = 0;
...
0
votes
1answer
33 views
php function for mySQL not working
this is my first ajax function that I am calling on from another page that sends a single array which is 9 entries of an integer over the $_POST.
The table has three rows (an ID increment, another ...
0
votes
0answers
51 views
PHP MySQL How can I paginate within two while loop
I would like to know how can I do a LIMIT 0,10 in this case (in order to do a pagination later) because when I do this I obtain a total of 30 results (10 results for each result of the first loop) ...
-2
votes
1answer
53 views
while inside foreach or while in php does not work [closed]
The while loop works only for the first record of the foreach value. I couldn't understand why. Any help would be greatly appreciated.
foreach($country_array as $country_new)
{
...
-1
votes
1answer
39 views
while inside while in php does not work [closed]
The while loop works only for the first record of the foreach value. I couldn't understand why. Any help would be greatly appreciated.
foreach($country_array as $country_new)
{
...
1
vote
2answers
61 views
PHP MYSQL SET gives error in while loop
I have this query:
$result2 = mysql_query("SET @total=0;
SELECT *,
@total:= @total+ `companyearned` AS `total`
FROM `recordedhours` WHERE `group` = '$uid'
ORDER BY `unixdate` DESC, `idnum` DESC
LIMIT ...
0
votes
1answer
22 views
Vimeo embed (froogaloop) SQL “while loop” issue
Link:
this is the page I am working on
So, I am trying to create a page that will produce a playlist of vimeo videos that will play one after another. Eventually I will have them hide ...
0
votes
2answers
27 views
Different value in While loop
i want to get only 4 values from while loop in different variables.For example i want like this
$Var1 = "value1";
$Var2 = "value2";
$Var3 = "value3";
$Var4 = "value4";
here is my while loop
...
0
votes
5answers
71 views
Update echoed data using WHILE loop. Only updates one record
I can't seem to be able to update any records except the first one.
I am not sure how to modify any of the displayed records.
<?php
if(isset($_POST["action"]) == "update")
{
$id = ...
0
votes
1answer
50 views
PHP Mysql COUNT results in a double loop
I would like to know how can I count the results in case I have two loop ! :
$select = "SELECT X FROM Y"
$result = mysql_query($select,$link);
$total = mysql_num_rows($result);
while($row = ...
-1
votes
2answers
90 views
While loop won't show first row
I am having trouble with a simple problem. I googled it and found so many resource but nothing is useful in my perspective.
Here I ran a query and output it as a select menu. But first row of the ...
-1
votes
6answers
72 views
Run a MySQL query inside a MySQL WHILE loop [closed]
I'm still new to php/sql so I was wondering if anyone could explain why this code won't work.
Everything runs fine except the second query inside the WHILE loop. Any help would be appreciated, ...
0
votes
1answer
52 views
cannot use while loop instead of foreach loop for pagination php mysql
How can I replace the foreach loop that displays content fetched from a table, to being display using this while loop?
code of foreach loop is here : http://pastebin.com/pWpLwVH3
the while loop code ...
0
votes
3answers
88 views
MySQL row count > 1 but SELECT only returns 1? [closed]
I have a simple MySQL query with PDO, which is SELECT * FROM table WHERE variable=:variable, and then I execute it. I grab the affected row count with the rowCount(); function, and that returns 20, ...
0
votes
1answer
48 views
MySQL: repeated insertion into a table
Given a book number id and the number of book copies, I want to insert as many rows into a table as there are book copies. This is my non-working solution:
DROP PROCEDURE IF EXISTS ...
-4
votes
0answers
46 views
PHP MySQL loop with two query [closed]
I have to do a SELECT * FROM table_X , the problem is table_X is the result of another query, so I want something like this :
<?php
$query1 = $bdd->("SELECT * FROM table_ref");
While ($data ...
1
vote
1answer
64 views
PHP and MySQL compare data
I have a database and in that database I have an ipbans table and then i also have a users table. the users table has a column called lastip and the ipbans table has a table called ip.
I need to ...
0
votes
0answers
65 views
Cross tabulation of query in php. Arrays, foreach loops…
I have a table setup with relationships as follows. A hierarchical structure where the root has a 1:1 relationship with subRoot table, which contains information related to the Root.
I can produce ...
0
votes
1answer
61 views
UPDATE all rows in while loop
I'm trying to wrap my brain around what I'm doing wrong here. This is the function that is called when I want to delete a record. The record is deleted, but I want the display_order to reestablish ...
0
votes
1answer
23 views
if loop to bold certain records and keep others non-bold
I'm trying to get returned records from the database. I'm looking to bold returned questions (returned = 1) and non-bold questions (returned = 0) that haven't been returned for this page ...
-2
votes
1answer
54 views
Error in MySQL and PHP statement [closed]
I have the following code, but it seems to break the page at the $result = $mysqli->query($query); statement. What am I doing wrong?
$ids = join(',',$newArray);
$query = "SELECT name, image FROM ...
0
votes
2answers
61 views
php/mysql array or query with some values
Hello I have this query
$upit = "SELECT id from usluga";
$rezultat = mysql_query($upit);
while($red = mysql_fetch_object($rezultat))
{
echo "<li>{$red->id}</li>";
}
I want on ...
-1
votes
1answer
67 views
script(while-loop) stops and no ouputs when multiple columns are selected
i want to select more than one columns from TABLE.but the script is not workling once the while loop starts. my php and html code is:
<table border="0">
include_once ...