obiwan Posted June 16, 2008 Share Posted June 16, 2008 Hey everyone I was wondering if anyone had any pointers in populating data into a div's instead of tables? For example I have created a simple registration form that uploads the users photograph, Name, basic information to that resembles a face book profile. Below is the code that diplays the user info but It looks plain and I am trying to figure out how to insert it into a more web 2.0 layout that I created: <? if((!$_POST[user_name]) || (!$_POST[user_password])) { header("Location: login.htm"); exit; print '<p>Please enter your username & password</p>'; } $db_name = "auth_users"; $table_name = "site_members"; $connection =@mysql_connect("myServerInfo","username","password") or die(mysql_error()); $db = @mysql_select_db($db_name,$connection) or die(mysql_error()); $sql = "SELECT * FROM $table_name WHERE username = '$_POST[user_name]' AND password = password('$_POST[user_password]')"; $result =@mysql_query($sql,$connection) or die(mysql_error()); $num = mysql_num_rows($result); if($num != 0) { $msg ="<p>Congratulations, you have successfully logged in!</p>"; //print out results while ($row = mysql_fetch_array($result)) { if ($row['photoUrlText'] != "") { print "<p>Welcome: {$row['f_name']} {$row['l_name']}</p>"; print "<img src='/photography/{$row['photoUrlText']}'>"; } } mysql_close(); //close connection } else { header("Location: login.htm"); exit; } ?> <? echo "$msg"; ?> Below is the layout that I am trying to populate: <div id="ProfileContainer"> <div id="mainProfile"> <div id="profilePhoto">Users Photography</div> <div id="nameContainer">Users Name</div> <div id="bDayContainer">Users Birthdate: 00/00/00</div> <div id="profileBody"></div> </div> Link to comment https://forums.phpfreaks.com/topic/110374-solved-inserting-data-from-mysql-into-a-div-with-php/ Share on other sites More sharing options...
tapos Posted June 16, 2008 Share Posted June 16, 2008 $sql = "SELECT * FROM $table_name WHERE username = '$_POST[user_name]' AND password = password('$_POST[user_password]')"; $result =@mysql_query($sql,$connection) or die(mysql_error()); $user_info = mysql_fetch_array($result); now in the div tag <div id="ProfileContainer"> <div id="mainProfile"> <div id="profilePhoto">Users Photography: <img src='/photography/<?php echo $user_info['photoUrlText']?>'></div> <div id="nameContainer"><?php echo $user_info['username']?></div> <div id="bDayContainer">Users Birthdate:<?php echo $user_info['birthday']?></div> <div id="profileBody"></div> </div> hope this will help u Link to comment https://forums.phpfreaks.com/topic/110374-solved-inserting-data-from-mysql-into-a-div-with-php/#findComment-566286 Share on other sites More sharing options...
obiwan Posted June 16, 2008 Author Share Posted June 16, 2008 Perfect that worked great thanks a lot! Link to comment https://forums.phpfreaks.com/topic/110374-solved-inserting-data-from-mysql-into-a-div-with-php/#findComment-566303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.