Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to keep one variable in memory
Message
From
24/02/2013 14:11:38
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01566822
Message ID:
01566830
Views:
38
Hi Naomi,

In fact, when I moved my mouse over the list of the article, I saw here "article.php?id=%d\ in the right bottom that let me

see for example number 5 if the article a.ID = 5 from my pick.

but how to keep that number in my second query, i don't know it.

Thx,


>>Hi all,
>>
>>I would like to keep one variable in memory for
>>my next sql query.
>>
>>
>>mysql_connect('localhost', 'root', '')
>>  or die("Mysql connection failed");
>>mysql_select_db("blog")
>>  or die("Can't find database 'blog'");
>>
>>
>>$sql = "select * from user,article where article.userID=user.ID order by article.ID desc limit 5";
>>$result = mysql_query($sql);
>>if (!$result)
>>	die("SQL error: ".$sql." ERROR: ".mysql_error());
>>
>>while ($row = mysql_fetch_assoc($result)) {
>>	printf("<hr><h3><a href=\"article.php?id=%d\">%s</a></h3><b>author %s, date %s</b><p>%s</p>",$row['ID'], 
>>	$row['title'], $row['username'],$row['timestamp'], $row['content']);	
>>	
>>}
>>
>>my next query to get id number id=%d , how to have it  ?
>>
>>$sql = "select a.ID,c.content from article as a inner join comment as c on a.ID = c.articleID
>>
>> group by a.ID,c.content order by a.ID desc limit 5  where a.ID = ???? ";
>>$result = mysql_query($sql);
>>if (!$result)
>>	die("SQL error: ".$sql." ERROR: ".mysql_error());
>>
>>while ($row = mysql_fetch_assoc($result)) {
>>  //printf($row['ID'],$row['content']);	
>>
>>  printf("<hr>%s<p>%s</p>",$row['ID'], $row['content']);	
>>}
>>
>>
>>
>>please help me, I really appreciated.
>>
>>Thank you,
>
>Are you using MySql or SQL Server? It looks like you need some sort of the loop and get values from the data in the first select. I think you may get better luck if you post this in PHP forum here. Also, perhaps another PHP forum (such as in tek-tips.com) may provide better answer.
Previous
Reply
Map
View

Click here to load this message in the networking platform