Re: Include Part 2
| From: | Justin French | Date: | Sun, 29 Sep 2002 06:31:05 +0000 |
| Subject: | Re: Include Part 2 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-118058@lists.php.net to get a copy of this message | ||
Is this to pull the rows out of a database??
You could start with a simple example, which is just a basic config setting,
and use the $myrow array in your sql while loop to do a lot of the work.
<?
// set your column names
$colsToSelect = 'title, format, category';
// select
$sql = "SELECT {$colsToSelect} FROM tablename LIMIT 2";
$result = mysql_query($sql);
while($myrow = mysql_fetch_array($result))
{
foreach($myrow as $key => $value)
{
echo "{$key}: {$value}<br />\n";
}
echo "<br />\n";
}
?>
For the above query, this would echo something like:
title: <contents of title><br />
format: <contents of format ><br />
category: <contents of category ><br />
<br />
title: <contents of title><br />
format: <contents of format ><br />
category: <contents of category ><br />
<br />
The next from there, to get more control over your rows might be an array
with the columns you wish to query...
Justin French
on 29/09/02 4:06 PM, Chuck PUP Payne (payne@magidesign.com) wrote:
> What I was wanting to do was store the myrows under let say, db_info.inc
> file. So that I can add or delete what myrows I want to call on.
>
> I am thinking this what I need to do...
>
> Function row ($row) { //These are the rows to call on...
> $title = $myrow[title];
> $format = myrow[format];
> $category =$myrow[category];
> }
>
> This way I can add more myrow to call upon at a later date or delete for
> that matter.
>
> I hope that helps...
>
> Chuck
>
> On 9/29/02 1:48 AM, "Justin French" <justin@indent.com.au> wrote:
>
>> Not sure I fully understand, but usually this stuff calls for either a
>> function, or an included file of code... in your case, sounds like a
>> function is required, but I may not fully understand...
>>
>> Regards,
>>
>> Justin
>>
>>
>> on 29/09/02 3:29 PM, Chuck PUP Payne (payne@magidesign.com) wrote:
>>
>>> Ok, I am trying to make my design a lot easier. I want to know if I can do
>>> this...
>>>
>>> I want to set up in my php page this...
>>>
>>>
>>> $rows;
>>>
>>> Under my db_info.inc I want to store this so that I can add delete from it.
>>>
>>> $row = "$title = myrow[title]; $format = myrow[format]; $category =
>>> myrow[category];"
>>>
>>> Am I wrong to try this way? Do I need to set it up as fuction to call on?
>>>
>>> Chuck Payne
>>>
>>
>