Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to keep one variable in memory
Message
 
 
À
24/02/2013 07:52:11
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01566822
Message ID:
01566826
Vues:
50
>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.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform