Re: can you have two sql statements on the same page.
| From: | Jack Sasportas | Date: | Wed, 21 Mar 2001 10:44:55 +0000 |
| Subject: | Re: can you have two sql statements on the same page. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-44918@lists.php.net to get a copy of this message | ||
The simple answer would be 2 while statements, but are you trying to mix the results
or are you keeping them seperate?
By mix there are 2 options
value_db1 Value_db2 Value_db1
or
value_db1
value_db1
value_db2
value_db1
by the simple answer above it would result in something like
Category #1
value_db1
value_db1
value_db1
value_db1
value_db1
Category #2
value_db2
value_db2
value_db2
value_db2
value_db2
or a side by side thing....
Also how many records (approx) are you dealing with ?
you could bring the value from each table into an array and then dump the values
stored in the array.
Hope this helps...
Jack
Matt Davis wrote:
> I want to extract 2 sets of data each from different tables in the same db
> but display the results on the same page at the same time. Can I just have
> two sql statements like this or do I need to do something else.
>
> //sql statement 1
> $sql1 = "select club_full_name from clubs where club_name = '$id'
> ";
>
> //sql statement 2
> $sql2 = "select message,message_title from noticeboard where club_name =
> '$id' ";
>
> //execute sql1 query and get results
> $sql_result1 = mysql_query($sql1);
>
> //execute sql2 query and get results
> $sql_result2 = mysql_query($sql2);
>
> /*results
> variables for data to be displayed*/
>
> while ($row = mysql_fetch_array($sql_result1)) {
> $name = $row["club_full_name"];
>
> }
>
> How can I put both sets of results in the while statement.
>
> Any help would be kindly appreciated
>
> Matt.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net