Jump to content

if and while loop issue


Pyro4816

Recommended Posts

It's kinda hard to explain the problem so i will show you.
[code] $result = $connector->query("SELECT * FROM messages WHERE
two='".$_SESSION['username']."' AND rd='0'");
$result2 = $connector->query("SELECT * FROM messages WHERE two='".$_SESSION['username']."' AND rd='0'");
$row9 = $connector->fetchArray($result2);
if ($row9['ID'] != ""){
echo '<b>RECEIVED</b><br /><table><tr><td>Title</td><td>From</td><td>Status</td></tr>';
while ($row = $connector->fetchArray($result)){[/code]
basically the issue is by the time i make it to the while loop i have moved on to the second result and on, i solved it by doing the same query twice and making to different "rows" is there a way to get my desired effect in one query?


All i really need is an if statement that can determine if the query is empty or not, any ideas?

ALSO, i have ben having a ton of problems with case sensitivity in databases, is there any way to fix that, like ill request items for Pyro and it returns things for Pyro and pyro but the system i am using is like  [code]if (name == $name){
}[/code]
where name is from the database and $name is a session, like it will only display is the two match exactly like:
Pyro = Pyro but if it is Pyro = pyro it errors.
Link to comment
https://forums.phpfreaks.com/topic/32395-if-and-while-loop-issue/
Share on other sites

[quote]ALSO, i have ben having a ton of problems with case sensitivity in databases, is there any way to fix that, like ill request items for Pyro and it returns things for Pyro and pyro but the system i am using is like
[code]if (name == $name){
}[/code]

where name is from the database and $name is a session, like it will only display is the two match exactly like:
Pyro = Pyro but if it is Pyro = pyro it errors.[/quote]
Use the identical operator === instead. This will then make the comparison case sensitive.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.