imarockstar Posted August 27, 2008 Share Posted August 27, 2008 I have joined these 2 tables (after a 90 page post yesterdsy ) ... so what I need is that if there is no data in the userinfo table .. i need it to display a link .... if there is data in the userinfo table i need it to display like it is below ... <?php //select the table $result2 = mysql_query("select * from userinfo where infoid = ". $_SESSION['userid']); // Retrieve data from database $result = mysql_query("SELECT * FROM users INNER JOIN usersinfo ON users.userid = usersinfo.infoid WHERE usersinfo.infoid = '{$_SESSION['userid']}' ") or die(mysql_error()); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)) { ?> <span class=dataleft>userid</span> <span class=dataright><? echo $rows['userid']; ?></span> <br class=clear> <span class=dataleft>username</span> <span class=dataright><? echo $rows['username']; ?></span> <br class=clear> <span class=dataleft>name:</span> <span class=dataright><? echo $rows['fname']; ?> <? echo $rows['lname']; ?></span> <br class=clear> <span class=dataleft>location</span> <span class=dataright><? echo $rows['city']; ?>, <? echo $rows['state']; ?> <? echo $rows['zipcode']; ?></span> <br class=clear> <span class=dataleft>sex</span> <span class=dataright><? echo $rows['sex']; ?></span> <br class=clear> <span class=dataleft>height</span> <span class=dataright><? echo $rows['height']; ?></span> <br class=clear> <span class=dataleft>weight</span> <span class=dataright><? echo $rows['weight']; ?></span> <br class=clear> <span class=dataleft>age</span> <span class=dataright><? echo $rows['age']; ?></span> <br class=clear> <div class=head1>your current gym</div> <div class=data1><? echo $rows['mygym']; ?></div> <div class=head1>your myspace</div> <div class=data1><? echo $rows['myspace']; ?></div> <div class=head1>your facebook</div> <div class=data1><? echo $rows['facebook']; ?></div> <div class=head1>your aim</div> <div class=data1><? echo $rows['aim']; ?></div> <div class=head1>your yahoo</div> <div class=data1><? echo $rows['yahoo']; ?></div> <? } ?> Link to comment https://forums.phpfreaks.com/topic/121593-solved-if-else-help/ Share on other sites More sharing options...
discomatt Posted August 27, 2008 Share Posted August 27, 2008 if ( mysql_num_rows($result) < 1 ) { # No rows } else { # Loop through rows } Link to comment https://forums.phpfreaks.com/topic/121593-solved-if-else-help/#findComment-627161 Share on other sites More sharing options...
imarockstar Posted August 27, 2008 Author Share Posted August 27, 2008 thanks .. that worked great !!! Link to comment https://forums.phpfreaks.com/topic/121593-solved-if-else-help/#findComment-627192 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.