Jump to content

[SOLVED] need help in php code


saad|_d3vil

Recommended Posts

Change your code to

<?php
$con = mysql_connect("localhost","apnimusk","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("apnimusk_naat", $con);

$result = mysql_query("SELECT * FROM album");

while($row = mysql_fetch_assoc($result))
{
    echo "<pre>".print_r($row, true)."</pre>";
    echo $row['name'] . " " . $row['age'];
    echo "<a href='?id='".$row['id']."'>".$row['age']."</a><br />'";
}

mysql_close($con);
?>

And post the output here.

Array

(

    [id] => 1

    [name] => Timmy Mellowman

    [age] => 23

)

 

Timmy Mellowman 2323

'

 

Array

(

    [id] => 2

    [name] => Sandy Smith

    [age] => 21

)

 

Sandy Smith 2121

'

 

Array

(

    [id] => 3

    [name] => Bobby Wallace

    [age] => 15

)

 

Bobby Wallace 1515

'

 

Array

(

    [id] => 7

    [name] =>

    [age] => 0

)

 

00

'

 

Array

(

    [id] => 8

    [name] =>

    [age] => 0

)

 

00

'

You need to add more code to display a new page, eg

<?php
$con = mysql_connect("localhost","apnimusk","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("apnimusk_naat", $con);

// check to see if id is set
if(isset($_GET['id']) && is_numeric($_GET['id']))
{
   echo 'Your have requested ID #'.$GET['id'].'<br />';
   echo '<a href="sadasdas.php">Back</a>';
}
// no id requested, display results
else
{
   $result = mysql_query("SELECT * FROM album");

   while($row = mysql_fetch_assoc($result))
   {
       echo '<a href="?id='.$row['id'].'">'.$row['age'].'</a> - ' . $row['name'] . " - " . $row['age'] . '<br />';
   }
}

mysql_close($con);
?>

can some explain me in detail please what i change in this code for makeing hyper link

echo "<a href='?id='".$row['id']."'>".$row['name']."</a>'";

remowe one ' after =

 

after click link in variable $_GET['id'] is value of id

where i put this code

can some explain me in detail please what i change in this code for makeing hyper link

echo "<a href='?id='".$row['id']."'>".$row['name']."</a>'";

remowe one ' after =

 

after click link in variable $_GET['id'] is value of id

where i put this code

No need to do that, I have already fixed that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.