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
Ralle
Forum Commoner
Posts: 38 Joined: Mon Oct 17, 2005 5:05 am
Post
by Ralle » Mon Oct 17, 2005 5:09 am
hello, here is my script!
Code: Select all
<?
//Variables
require_once('connect.php');
$cat = $_GET[id];
if ($cat == NULL) {$cat = 0;}
$resulta = mysql_query("SELECT * FROM categories WHERE cats_approved=1 AND cats_subcat=$cat");
$resultb = mysql_query("SELECT * FROM links WHERE links_cat=$cat");
//Categories
while ($row = mysql_fetch_array($resulta, MYSQL_BOTH))
{
$i++;
if ($i == 1) {echo 'categories<br><table border="1">';}
$link = "<a href=" . viewcats . "?id=" . $row['cats_id'] . ">" . $row['cats_name'] . "</a>";
echo "<tr><td>$link</td></tr>";
}
if ($i > 0) {echo "</table>";}
//echo "<a href=" . viewcats . "?id=$cat>back</a>";
//Output Links
while ($row = mysql_fetch_array($resultb, MYSQL_BOTH))
{
$o++;
if ($i == 0) {echo 'links<br><table border="1">';}
$link = "<a href=" . viewlink . "?id=" . $row['links_id'] . ">" . $row['links_name'] . "</a><br>";
$url = $row['links_url'];
$description = $row['links_desc'];
$hits = $row['links_hits'];
$banner = $row['links_banner'];
echo "<tr><td>$link<br>$description</td></tr>";
}
if ($o > 0) {echo "</table>";}
?>
I would like to have the variables $row to be a multi variable so if I wrote:
it would say some number. I want everything it pulls out of the database in this small $row. how is that possible?
NOTE: I played around with it but didnt make it to work, listed above is my backup script.
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Oct 17, 2005 5:16 am
Code: Select all
<?
while ($row = mysql_fetch_array($resultb, MYSQL_BOTH))
{
$o++;
if ($i == 0) {echo 'links<br><table border="1">';}
$link = "<a href=" . viewlink . "?id=" . $row['links_id'] . ">" . $row['links_name'] . "</a><br>";
$url = $row['links_url'];
$description = $row['links_desc'];
$hits = $row['links_hits'];
$banner = $row['links_banner'];
$new_row[$o]['links_url'] = $row['links_url']; //repeat this with the rest of the $row things
echo "<tr><td>$link<br>$description</td></tr>";
}
if ($o > 0) {echo "</table>";}
print_r($new_row);
?>
is that what you mean?
Ralle
Forum Commoner
Posts: 38 Joined: Mon Oct 17, 2005 5:05 am
Post
by Ralle » Mon Oct 17, 2005 5:46 am
Thank you man!
I will add this site to favorites!
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Oct 17, 2005 7:13 am
Ralle wrote: Thank you man!
I will add this site to favorites!
thats a very good idea.
Jenk
DevNet Master
Posts: 3587 Joined: Mon Sep 19, 2005 6:24 am
Location: London
Post
by Jenk » Mon Oct 17, 2005 11:12 am
Code: Select all
<?php
$rows = array();
while ($row = mysql_fetch_array($result)) {
$rows[] = $row;
}
?>