two or more SELECT in the data base

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hutygoo
Forum Newbie
Posts: 1
Joined: Thu Jul 27, 2006 4:27 pm

two or more SELECT in the data base

Post by hutygoo »

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I do not obtain to make two or more SELECT in the data base MySql for the same archive. To select two or more Tables. Please they help me

  

Seg Ago 07, 2006 9:25
	{L_BACK_TO_TOP}Responder com CitaçãoEditar/Remover esta mensagem

Code: Select all

<?
include ("conex.php");

$query_a = "SELECT titulo_textopolemica, titulo_imgpolemica FROM titulo";
$result = mysql_query($query_a);

$query_b = "SELECT texto_polemica FROM texto";
$result = mysql_query($query_b);

$query_c = "SELECT autor_imgpolemica, autor_textopolemica FROM autor";
$result = mysql_query($query_c);

$num = mysql_num_rows($result);
mysql_close();

$i=0;



while ($i < $num){
$titulo_textopolemica = mysql_result ($result,$i,"titulo_textopolemica");
$titulo_imgpolemica = mysql_result ($result,$i,"titulo_imgpolemica"); // essa barra nao funciona
$texto_polemica = mysql_result ($result,$i,"texto_polemica"); //essa barra tambem não
$autor_imgpolemica = mysql_result ($result,$i,"autor_imgpolemica"); //""""
$autor_textopolemica = mysql_result ($result,$i,"autor_textopolemica");//"""
$i++;
?>
<div id="content">

<h1 class="LinkLocal">Polemica</h1>
<div>
<!--<img src=".../images/img_dosTextos.png" />--></div>
<h2 Class="TituloLocal"><? echo"$titulo_textopolemica";?></h2>
<h2>
<img src=".../images/imgdemos.png" />
</h2>
<h2 class="TituloLocal"><? echo"$titulo_imgpolemica";?></h2>
<h4 class="autos"><? echo"$autor_textopolemica";?></h4>
<h3 class="textoLocal">

<? echo"$texto_polemica" ?>

</h3>

</div>


<?
}
?>

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

If I am reading this correctly, try this...

Code: Select all

<?php
$query_a = "SELECT titulo_textopolemica, titulo_imgpolemica FROM titulo";
$result_a = mysql_query($query_a) or die('Q_A failed: ' . mysql_error());

$query_b = "SELECT texto_polemica FROM texto";
$result_b = mysql_query($query_b) or die('Q_B failed: ' . mysql_error());

$query_c = "SELECT autor_imgpolemica, autor_textopolemica FROM autor";
$result_c = mysql_query($query_c) or die('Q_C failed: ' . mysql_error());

$num_a = mysql_num_rows($result_a);
$num_b = mysql_num_rows($result_b);
$num_c = mysql_num_rows($result_c);
mysql_close(); 
?>
Then change all of your references to $result to the appropriate $result_*.
Post Reply