Reused while loop only working for one selection boxEmulate a do-while loop in Python?How to POST empty <select .. multiple> HTML elements if empty?Syntax for a single-line Bash infinite while loopHow to style a <select> dropdown with only CSS?Set selected option of select boxHow do I make a placeholder for a 'select' box?$_POST is empty when submitting a value that was posted to the formHow to pass select box value to PHP variable on same page?Disable <select> option when selected in another <select> boxIssue filling selection box with PHP from database
Why does the U.S. military maintain their own weather satellites?
Is the net torque changed when a partner on a seesaw stands or hangs from her end instead of sitting?
Can you use Apple Care+ without any checks (bringing just MacBook)?
Can I leave a large suitcase at TPE during a 4-hour layover, and pick it up 4.5 days later when I come back to TPE on my way to Taipei downtown?
Sum and average calculator
How can I improve my formal definitions?
apt-file regex: find multiple packages at once using or
A word for the urge to do the opposite
Ideas behind the 8.Bd3 line in the 4.Ng5 Two Knights Defense
Can the inductive kick be discharged without a freewheeling diode, in this example?
Do universities maintain secret textbooks?
Fishing from underwater domes
How many possible file types in the output `ls -l` command?
Break down the phrase "shitsurei shinakereba naranaindesu"
What is this "opened" cube called?
Can a system of three stars exist?
How would a disabled person earn their living in a medieval-type town?
When you have to wait for a short time
How does the search space affect the speed of an ILP solver?
A vector is defined to have a magnitude and *a* direction, but the zero vector has no *single* direction. So, how is the zero vector a vector?
Can a human variant take proficiency in initiative?
how can reincarnation magic be limited to prevent overuse?
Confidence intervals for the mean of a sample of counts
Cheap oscilloscope showing 16 MHz square wave
Reused while loop only working for one selection box
Emulate a do-while loop in Python?How to POST empty <select .. multiple> HTML elements if empty?Syntax for a single-line Bash infinite while loopHow to style a <select> dropdown with only CSS?Set selected option of select boxHow do I make a placeholder for a 'select' box?$_POST is empty when submitting a value that was posted to the formHow to pass select box value to PHP variable on same page?Disable <select> option when selected in another <select> boxIssue filling selection box with PHP from database
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I need to generate a list of teams from the cups selection box at the top of my page, this code allows me to run a while loop to generate the correct results for the first selection box, however, when i replicate the code in the second it shows no results?
<form class="seed-form">
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
while ($team = mysqli_fetch_assoc($show_teams)) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
while ($team = mysqli_fetch_assoc($show_teams)) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<input type="submit" name="submit" value="Generate" class="submit">
<?php
if (isset($_POST['submit'])) //checking if submit button was clicked
include_once 'action/dbcon.php';
$cname = $_POST['cupname'];
if (empty($cname))
header("Location: tables.php?field=empty"); //return them if fields are empty
exit();
else
$sql = "SELECT * FROM teams WHERE cup_name='$cname'";
$show_teams = mysqli_query($conn, $sql);
$numberCheck = mysqli_num_rows($show_teams);
if ($numberCheck < 8)
header("Location: tables.php?tables=1"); //Take to cup page if there arent enough teams in the cup
?>
php html while-loop
add a comment |
I need to generate a list of teams from the cups selection box at the top of my page, this code allows me to run a while loop to generate the correct results for the first selection box, however, when i replicate the code in the second it shows no results?
<form class="seed-form">
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
while ($team = mysqli_fetch_assoc($show_teams)) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
while ($team = mysqli_fetch_assoc($show_teams)) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<input type="submit" name="submit" value="Generate" class="submit">
<?php
if (isset($_POST['submit'])) //checking if submit button was clicked
include_once 'action/dbcon.php';
$cname = $_POST['cupname'];
if (empty($cname))
header("Location: tables.php?field=empty"); //return them if fields are empty
exit();
else
$sql = "SELECT * FROM teams WHERE cup_name='$cname'";
$show_teams = mysqli_query($conn, $sql);
$numberCheck = mysqli_num_rows($show_teams);
if ($numberCheck < 8)
header("Location: tables.php?tables=1"); //Take to cup page if there arent enough teams in the cup
?>
php html while-loop
1
Warning: Your code is vulnerable to SQL Injection attacks. You should use parameterised queries and prepared statements to help prevent attackers from compromising your database by using malicious input values. bobby-tables.com gives an explanation of the risks, as well as some examples of how to write your queries safely using PHP / mysqli. Never insert unsanitised data directly into your SQL. The way your code is written now, someone could easily steal, incorrectly change, or even delete your data.
– ADyson
Mar 27 at 23:56
add a comment |
I need to generate a list of teams from the cups selection box at the top of my page, this code allows me to run a while loop to generate the correct results for the first selection box, however, when i replicate the code in the second it shows no results?
<form class="seed-form">
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
while ($team = mysqli_fetch_assoc($show_teams)) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
while ($team = mysqli_fetch_assoc($show_teams)) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<input type="submit" name="submit" value="Generate" class="submit">
<?php
if (isset($_POST['submit'])) //checking if submit button was clicked
include_once 'action/dbcon.php';
$cname = $_POST['cupname'];
if (empty($cname))
header("Location: tables.php?field=empty"); //return them if fields are empty
exit();
else
$sql = "SELECT * FROM teams WHERE cup_name='$cname'";
$show_teams = mysqli_query($conn, $sql);
$numberCheck = mysqli_num_rows($show_teams);
if ($numberCheck < 8)
header("Location: tables.php?tables=1"); //Take to cup page if there arent enough teams in the cup
?>
php html while-loop
I need to generate a list of teams from the cups selection box at the top of my page, this code allows me to run a while loop to generate the correct results for the first selection box, however, when i replicate the code in the second it shows no results?
<form class="seed-form">
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
while ($team = mysqli_fetch_assoc($show_teams)) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
while ($team = mysqli_fetch_assoc($show_teams)) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<input type="submit" name="submit" value="Generate" class="submit">
<?php
if (isset($_POST['submit'])) //checking if submit button was clicked
include_once 'action/dbcon.php';
$cname = $_POST['cupname'];
if (empty($cname))
header("Location: tables.php?field=empty"); //return them if fields are empty
exit();
else
$sql = "SELECT * FROM teams WHERE cup_name='$cname'";
$show_teams = mysqli_query($conn, $sql);
$numberCheck = mysqli_num_rows($show_teams);
if ($numberCheck < 8)
header("Location: tables.php?tables=1"); //Take to cup page if there arent enough teams in the cup
?>
php html while-loop
php html while-loop
asked Mar 27 at 23:53
Brad ArcherBrad Archer
164 bronze badges
164 bronze badges
1
Warning: Your code is vulnerable to SQL Injection attacks. You should use parameterised queries and prepared statements to help prevent attackers from compromising your database by using malicious input values. bobby-tables.com gives an explanation of the risks, as well as some examples of how to write your queries safely using PHP / mysqli. Never insert unsanitised data directly into your SQL. The way your code is written now, someone could easily steal, incorrectly change, or even delete your data.
– ADyson
Mar 27 at 23:56
add a comment |
1
Warning: Your code is vulnerable to SQL Injection attacks. You should use parameterised queries and prepared statements to help prevent attackers from compromising your database by using malicious input values. bobby-tables.com gives an explanation of the risks, as well as some examples of how to write your queries safely using PHP / mysqli. Never insert unsanitised data directly into your SQL. The way your code is written now, someone could easily steal, incorrectly change, or even delete your data.
– ADyson
Mar 27 at 23:56
1
1
Warning: Your code is vulnerable to SQL Injection attacks. You should use parameterised queries and prepared statements to help prevent attackers from compromising your database by using malicious input values. bobby-tables.com gives an explanation of the risks, as well as some examples of how to write your queries safely using PHP / mysqli. Never insert unsanitised data directly into your SQL. The way your code is written now, someone could easily steal, incorrectly change, or even delete your data.
– ADyson
Mar 27 at 23:56
Warning: Your code is vulnerable to SQL Injection attacks. You should use parameterised queries and prepared statements to help prevent attackers from compromising your database by using malicious input values. bobby-tables.com gives an explanation of the risks, as well as some examples of how to write your queries safely using PHP / mysqli. Never insert unsanitised data directly into your SQL. The way your code is written now, someone could easily steal, incorrectly change, or even delete your data.
– ADyson
Mar 27 at 23:56
add a comment |
1 Answer
1
active
oldest
votes
The problem is that fetch_assoc()
returns the next row in the resultset, unless there are no more left (in which case it returns NULL
- see docs).
Your first while
loop runs until there are no more results. Therefore when you start the second while
loop, there are still...you guessed it: no more results. You already used them up. Therefore the first call to fetch_assoc()
in the second loop returns NULL
immediately, and so the loop condition is never met, and the loop never executes.
There are two different ways to solve this:
1) Reset the result pointer to the start of the resultset. Somewhere between the two loops, write
mysqli_data_seek($show_teams, 0);
See docs for more info.
2) Read all the data into a PHP array, which you can then loop through as many times as you like using foreach
:
<?php
$teams = array();
while ($team = mysqli_fetch_assoc($show_teams))
$teams[] = $team;
?>
<form class="seed-form">
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?><!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
Both methods are throwing Notice: Undefined variable: show_teams in C:xampphtdocsfriendlyfixturestables.php on line 96 and Warning: mysqli_data_seek() expects parameter 1 to be mysqli_result, null given in C:xampphtdocsfriendlyfixturestables.php on line 101
– Brad Archer
Mar 28 at 0:17
According to the code in your question,$show_teams
is your query result object. So that's why I used that name. Maybe you changed it in the meantime or something?
– ADyson
Mar 28 at 0:18
none of the variable names were changed hence why im extremely confused, dont suppose you have any clue?
– Brad Archer
Mar 28 at 0:26
I can't see how you run the query and assign the result, so it's hard to be sure. Can you add that to the code in the question?
– ADyson
Mar 28 at 0:29
Not to worry, i placed the data seek elsewhere, now the variable is being recognised. However, i do also appreciate the array solution, thanks for the help!
– Brad Archer
Mar 28 at 0:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388200%2freused-while-loop-only-working-for-one-selection-box%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is that fetch_assoc()
returns the next row in the resultset, unless there are no more left (in which case it returns NULL
- see docs).
Your first while
loop runs until there are no more results. Therefore when you start the second while
loop, there are still...you guessed it: no more results. You already used them up. Therefore the first call to fetch_assoc()
in the second loop returns NULL
immediately, and so the loop condition is never met, and the loop never executes.
There are two different ways to solve this:
1) Reset the result pointer to the start of the resultset. Somewhere between the two loops, write
mysqli_data_seek($show_teams, 0);
See docs for more info.
2) Read all the data into a PHP array, which you can then loop through as many times as you like using foreach
:
<?php
$teams = array();
while ($team = mysqli_fetch_assoc($show_teams))
$teams[] = $team;
?>
<form class="seed-form">
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?><!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
Both methods are throwing Notice: Undefined variable: show_teams in C:xampphtdocsfriendlyfixturestables.php on line 96 and Warning: mysqli_data_seek() expects parameter 1 to be mysqli_result, null given in C:xampphtdocsfriendlyfixturestables.php on line 101
– Brad Archer
Mar 28 at 0:17
According to the code in your question,$show_teams
is your query result object. So that's why I used that name. Maybe you changed it in the meantime or something?
– ADyson
Mar 28 at 0:18
none of the variable names were changed hence why im extremely confused, dont suppose you have any clue?
– Brad Archer
Mar 28 at 0:26
I can't see how you run the query and assign the result, so it's hard to be sure. Can you add that to the code in the question?
– ADyson
Mar 28 at 0:29
Not to worry, i placed the data seek elsewhere, now the variable is being recognised. However, i do also appreciate the array solution, thanks for the help!
– Brad Archer
Mar 28 at 0:35
add a comment |
The problem is that fetch_assoc()
returns the next row in the resultset, unless there are no more left (in which case it returns NULL
- see docs).
Your first while
loop runs until there are no more results. Therefore when you start the second while
loop, there are still...you guessed it: no more results. You already used them up. Therefore the first call to fetch_assoc()
in the second loop returns NULL
immediately, and so the loop condition is never met, and the loop never executes.
There are two different ways to solve this:
1) Reset the result pointer to the start of the resultset. Somewhere between the two loops, write
mysqli_data_seek($show_teams, 0);
See docs for more info.
2) Read all the data into a PHP array, which you can then loop through as many times as you like using foreach
:
<?php
$teams = array();
while ($team = mysqli_fetch_assoc($show_teams))
$teams[] = $team;
?>
<form class="seed-form">
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?><!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
Both methods are throwing Notice: Undefined variable: show_teams in C:xampphtdocsfriendlyfixturestables.php on line 96 and Warning: mysqli_data_seek() expects parameter 1 to be mysqli_result, null given in C:xampphtdocsfriendlyfixturestables.php on line 101
– Brad Archer
Mar 28 at 0:17
According to the code in your question,$show_teams
is your query result object. So that's why I used that name. Maybe you changed it in the meantime or something?
– ADyson
Mar 28 at 0:18
none of the variable names were changed hence why im extremely confused, dont suppose you have any clue?
– Brad Archer
Mar 28 at 0:26
I can't see how you run the query and assign the result, so it's hard to be sure. Can you add that to the code in the question?
– ADyson
Mar 28 at 0:29
Not to worry, i placed the data seek elsewhere, now the variable is being recognised. However, i do also appreciate the array solution, thanks for the help!
– Brad Archer
Mar 28 at 0:35
add a comment |
The problem is that fetch_assoc()
returns the next row in the resultset, unless there are no more left (in which case it returns NULL
- see docs).
Your first while
loop runs until there are no more results. Therefore when you start the second while
loop, there are still...you guessed it: no more results. You already used them up. Therefore the first call to fetch_assoc()
in the second loop returns NULL
immediately, and so the loop condition is never met, and the loop never executes.
There are two different ways to solve this:
1) Reset the result pointer to the start of the resultset. Somewhere between the two loops, write
mysqli_data_seek($show_teams, 0);
See docs for more info.
2) Read all the data into a PHP array, which you can then loop through as many times as you like using foreach
:
<?php
$teams = array();
while ($team = mysqli_fetch_assoc($show_teams))
$teams[] = $team;
?>
<form class="seed-form">
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?><!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
The problem is that fetch_assoc()
returns the next row in the resultset, unless there are no more left (in which case it returns NULL
- see docs).
Your first while
loop runs until there are no more results. Therefore when you start the second while
loop, there are still...you guessed it: no more results. You already used them up. Therefore the first call to fetch_assoc()
in the second loop returns NULL
immediately, and so the loop condition is never met, and the loop never executes.
There are two different ways to solve this:
1) Reset the result pointer to the start of the resultset. Somewhere between the two loops, write
mysqli_data_seek($show_teams, 0);
See docs for more info.
2) Read all the data into a PHP array, which you can then loop through as many times as you like using foreach
:
<?php
$teams = array();
while ($team = mysqli_fetch_assoc($show_teams))
$teams[] = $team;
?>
<form class="seed-form">
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?><!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
<select name="team" required>
<option value='Holder' disabled selected>Select Team</option> <!--Placeholder for Select-->
<?php
foreach ($teams as $team) ?>
<option value="<?php echo $team["team_id"]; ?>"><?php echo $team["team_name"]; ?></option>
<?php ?> <!--FILLS SELECT BOX WITH TEAMS FROM THAT CUP-->
</select>
answered Mar 28 at 0:03
ADysonADyson
29.3k12 gold badges28 silver badges46 bronze badges
29.3k12 gold badges28 silver badges46 bronze badges
Both methods are throwing Notice: Undefined variable: show_teams in C:xampphtdocsfriendlyfixturestables.php on line 96 and Warning: mysqli_data_seek() expects parameter 1 to be mysqli_result, null given in C:xampphtdocsfriendlyfixturestables.php on line 101
– Brad Archer
Mar 28 at 0:17
According to the code in your question,$show_teams
is your query result object. So that's why I used that name. Maybe you changed it in the meantime or something?
– ADyson
Mar 28 at 0:18
none of the variable names were changed hence why im extremely confused, dont suppose you have any clue?
– Brad Archer
Mar 28 at 0:26
I can't see how you run the query and assign the result, so it's hard to be sure. Can you add that to the code in the question?
– ADyson
Mar 28 at 0:29
Not to worry, i placed the data seek elsewhere, now the variable is being recognised. However, i do also appreciate the array solution, thanks for the help!
– Brad Archer
Mar 28 at 0:35
add a comment |
Both methods are throwing Notice: Undefined variable: show_teams in C:xampphtdocsfriendlyfixturestables.php on line 96 and Warning: mysqli_data_seek() expects parameter 1 to be mysqli_result, null given in C:xampphtdocsfriendlyfixturestables.php on line 101
– Brad Archer
Mar 28 at 0:17
According to the code in your question,$show_teams
is your query result object. So that's why I used that name. Maybe you changed it in the meantime or something?
– ADyson
Mar 28 at 0:18
none of the variable names were changed hence why im extremely confused, dont suppose you have any clue?
– Brad Archer
Mar 28 at 0:26
I can't see how you run the query and assign the result, so it's hard to be sure. Can you add that to the code in the question?
– ADyson
Mar 28 at 0:29
Not to worry, i placed the data seek elsewhere, now the variable is being recognised. However, i do also appreciate the array solution, thanks for the help!
– Brad Archer
Mar 28 at 0:35
Both methods are throwing Notice: Undefined variable: show_teams in C:xampphtdocsfriendlyfixturestables.php on line 96 and Warning: mysqli_data_seek() expects parameter 1 to be mysqli_result, null given in C:xampphtdocsfriendlyfixturestables.php on line 101
– Brad Archer
Mar 28 at 0:17
Both methods are throwing Notice: Undefined variable: show_teams in C:xampphtdocsfriendlyfixturestables.php on line 96 and Warning: mysqli_data_seek() expects parameter 1 to be mysqli_result, null given in C:xampphtdocsfriendlyfixturestables.php on line 101
– Brad Archer
Mar 28 at 0:17
According to the code in your question,
$show_teams
is your query result object. So that's why I used that name. Maybe you changed it in the meantime or something?– ADyson
Mar 28 at 0:18
According to the code in your question,
$show_teams
is your query result object. So that's why I used that name. Maybe you changed it in the meantime or something?– ADyson
Mar 28 at 0:18
none of the variable names were changed hence why im extremely confused, dont suppose you have any clue?
– Brad Archer
Mar 28 at 0:26
none of the variable names were changed hence why im extremely confused, dont suppose you have any clue?
– Brad Archer
Mar 28 at 0:26
I can't see how you run the query and assign the result, so it's hard to be sure. Can you add that to the code in the question?
– ADyson
Mar 28 at 0:29
I can't see how you run the query and assign the result, so it's hard to be sure. Can you add that to the code in the question?
– ADyson
Mar 28 at 0:29
Not to worry, i placed the data seek elsewhere, now the variable is being recognised. However, i do also appreciate the array solution, thanks for the help!
– Brad Archer
Mar 28 at 0:35
Not to worry, i placed the data seek elsewhere, now the variable is being recognised. However, i do also appreciate the array solution, thanks for the help!
– Brad Archer
Mar 28 at 0:35
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388200%2freused-while-loop-only-working-for-one-selection-box%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Warning: Your code is vulnerable to SQL Injection attacks. You should use parameterised queries and prepared statements to help prevent attackers from compromising your database by using malicious input values. bobby-tables.com gives an explanation of the risks, as well as some examples of how to write your queries safely using PHP / mysqli. Never insert unsanitised data directly into your SQL. The way your code is written now, someone could easily steal, incorrectly change, or even delete your data.
– ADyson
Mar 27 at 23:56