Jump to content

Archived

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

xCypherx

MySQL Query Problems

Recommended Posts

hmm for some reason my script will only show 1 field when it should show 2 both with images see if you can see whats wrong with my script :( i know its messy, but im quite new...

 

<?php
$username="user";
$password="pass";
$database="db1";

mysql_connect("localhost",$username,$password);
@mysql_select_db($database) OR die( "Unable to select database");
$query="SELECT * FROM ibf_members WHERE (`mgroup`='6' OR `mgroup_others`='6') ORDER BY `joined`";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center>Roster</center></b><br>";

$i=0;
while ($i < $num) {
echo($num);

$name=mysql_result($result,$i,"name");
$email=mysql_result($result,$i,"email");
$id=mysql_result($result,$i,"id");


mysql_connect("localhost",$username,$password);
@mysql_select_db($database) OR die( "Unable to select database");
$sql="SELECT * FROM ibf_pfields_content WHERE (`member_id`='$id')";
$result2=mysql_query($sql);
$num=mysql_numrows($result2);

mysql_close();


$image=mysql_result($result2,$i,"field_2");
?>

<font face="Arial, Helvetica, sans-serif"><a href="index.php?showuser=<? echo $id; ?>"><? echo $name; ?></a><img src=/style_flags/<? echo $image; ?>></font><br>

<?php
$i++;
}


?> 

Share this post


Link to post
Share on other sites

hi, duno if this seems easier for u, but i find it easier to do things like this..

 

$db = mysql_connect("localhost", "user", "pass");

mysql_select_db("database_name", $db);

 

$result = mysql_query("SELECT * FROM table_name ORDER BY sumink_like_id_is_always_good ASC", $db);

 

while($row=mysql_fetch_array($result))

{

 

echo("name ur field:" . $row['field_name']);

echo("if more than one thing u can do it like this");

echo("1: " . $row['field_name'] . " 2: " . $row['2nd_field'] . ");

 

}

 

mysql_close();

 

---

 

hope this helps..

 

khuti

Share this post


Link to post
Share on other sites

×

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.