Jump to content

MySQL Query Problems


xCypherx

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++;
}


?> 

Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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