Viewed   74 times

I have a table in a database called Artists. It contains two bands. What I would like to do is to be able to click on the bands name using a hyper link, send that bands name to another php page to be processed

The hyper link syntax i have is throwing up errors:

$query = "SELECT * FROM artists";

$result = mysql_query($query);

while($row = mysql_fetch_array($result))
    "<a target='Main_Frame' href=Side_Menu_ContentPrint.php?Aname=<?php echo 
    $_POST['ArtistName'] ?>" . $row['ArtistName'] . "</a>";         

So I would like the above hyperlink to pass the bands name to Side_Menu_ContentPrint.php file so I can echo it to the screen (and use for more DB querying also). This file connects to the DB and contains:

$artist_Name = $_GET['Aname'];

echo "$artist_Name";

Just to show also, the following hyper link is working:

while($row = mysql_fetch_array($result))
   "<a target='Main_Frame' href=Side_Menu_ContentPrint.php>" . $row['ArtistName'] . "  

and when click on it echos a test word to prove that it is working. Any help would be great?

Regards, TW



you can't put PHP code into echo and hope that it will run again.

Try this,

"<a target='Main_Frame' href='Side_Menu_ContentPrint.php?Aname=" . $row['ArtistName'] ."'>". $row['ArtistName'] . "</a>";     
Thursday, August 11, 2022

just change to lowercase first letter in bindParam();

$stmt->bindParam(':rent_occupancy_id', $rent_occupancy_id);
$stmt->bindParam(':rent_cost', $rent_cost);
$stmt->bindParam(':date_lastpaid', $date_lastpaid);
$stmt->bindParam(':date_due', $date_due);
Wednesday, October 19, 2022

You could give alias at the sql stmt.

SELECT ttype.TyName, train.TraNo, a.StaName as dstation, c.Time as dtime,b.StaName as astation , d.Time as atime

When retrieve, retrieve using

 <?php echo $row['dstation']?>
 <?php echo $row['dTime']?>
 <?php echo $row['astation']?>
 <?php echo $row['aTime']?>
Friday, August 5, 2022

Just allow column university_id of table user to allow NULL value so you can save nulls.

   uid INT NOT NULL,
   Name VARCHAR(30) NOT NULL, 
   university_ID INT NULL,    -- <<== this will allow field to accept NULL
   CONSTRAINT user_fk FOREIGN KEY (university_ID)
       REFERENCES university(university_ID)


based on your comment, you should be inserting NULL and not ''.

insert into user (name,university_id) values ('harjeet', NULL)


$university_id = !empty($university_id) ? "'$university_id'" : "NULL";
insert into user (name,university_id) values ('harjeet', $university_id);

As a sidenote, the query is vulnerable with SQL Injection if the value(s) of the variables came from the outside. Please take a look at the article below to learn how to prevent from it. By using PreparedStatements you can get rid of using single quotes around values.

  • How to prevent SQL injection in PHP?
Monday, December 5, 2022

Only form elements are posted back to the server. You need to create an input element if you want the value sent. You could consider making an <input type="hidden" name="test" value="testvalue".

In response to your custom checkbox made with jQuery comment, you could use jQuery to set the value of the hidden input element. This will let you continue to use the div but have a value that gets sent back to the server.

Monday, August 1, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :