Welcome Guest, Not a member yet? Register   Sign In
Need help with database querys
#1

[eluser]Unknown[/eluser]
I want to show the username in a blogpost. The username and the blogpost are in different tables. This is my old solution:
1.
$sql = “SELECT * FROM blogs WHERE entry_id = $_GET['entry_id']";
$data = mysqli_query($db, $sql);
$row= mysqli_fetch_array($data);
echo $row[‘user_id’];

2.
// Username
$sql2 = "SELECT * FROM users WHERE user_id = $row[‘user_id’]";
$data2 = mysqli_query($db, $sql2);
$row2 = mysqli_fetch_array($data2);
echo $row[‘username’];

Is there a nicer solution with codeigniter? I would prefer to use model and controller. I hope anyone can help me Smile


Messages In This Thread
Need help with database querys - by El Forum - 01-31-2011, 07:00 AM
Need help with database querys - by El Forum - 01-31-2011, 07:28 AM
Need help with database querys - by El Forum - 01-31-2011, 07:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB