Welcome Guest, Not a member yet? Register   Sign In
new user help
#1

[eluser]B3ll4triX[/eluser]
I am use CI for the first time. I have a poblem. I have 2 table article and category. In category table, i have 3 fields (category_id, name, description). In article table, i have 4 fields (id, headline, description, category_id). The problem is, how to write the MVC in CI, if the finished look like this:

headline: The CI Contructor
description: --- description here ---
category_name: --- name of category here ---

headline: The CI Contructor 2
description: --- description here 2 ---
category_name: --- name of category here 2 ---
.
:

I am always write 2 looping in this case,
<?php
include('./adodb/adodb.inc.php');
$sql = "SELECT * FROM article";
$query = $conn->Execute($sql);
while(!$query->EOF){
echo "headline: ".$query->fields[1]."<br>";
echo "description: ".$query->fields[2]."<br>";

$sql2 = "SELECT category_id, name FROM category
WHERE category_id = '".$conn->fields[3]."'";
$query2 = $conn->Execute($sql2);
echo "category_name: ".$query2->fields[1];
echo "<br><br>";
$conn->MoveNext();
}

?&gt;

- thank's b4 -


Messages In This Thread
new user help - by El Forum - 04-16-2008, 06:49 PM
new user help - by El Forum - 04-16-2008, 07:05 PM
new user help - by El Forum - 04-16-2008, 10:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB