help me code better
Posted: Thu Oct 29, 2009 12:54 am
//please correct my logic. I need to make those variables $topicid, $topic, $sentid & $sent as arrays which I need to use them outside those local loops.
Need to concatenate every $topic[] with every $sent[]. Please help me code better.
Code: Select all
<?php
require_once("includes/connection.php");
$topics = mysql_query("SELECT * FROM trendingtopics ORDER BY topicid") or die(mysql_error());
$num_rows_topics = mysql_num_rows($topics);
if ($num_rows_topics < 1) {
echo "No topics";
}
else {
while($row_topics = mysql_fetch_array($topics))
{
$topicid = $row_topics['topicid'];
$topic = $row_topics['topic'];
//echo $topicid.'<br \>';
//echo $topic.'<br \>';
}
}
$sentences = mysql_query("SELECT * FROM sentences ORDER BY sentid") or die(mysql_error());
$num_rows_sentences = mysql_num_rows($sentences);
if ($num_rows_sentences < 1) {
echo "No sentences";
}
else {
while($row_sentences = mysql_fetch_array($sentences))
{
$sentid = $row_sentences['sentid'];
$sent = $row_sentences['sent'];
//echo $sentid.'<br \>';
//echo $sent.'<br \>';
}
}
?>