Jump to content

query db and get results into hyperlink


jjmusicpro

Recommended Posts

Eekkk just cant figure it out, always comes back with a blank page :(

 

<?php
//Paused Clients Query
parse_str("$QUERY_STRING");
$db = mysql_connect("localhost", "xxxx","xxxxxxx") or die("Could not connect.");
if(!$db) 
die("no db");
if(!mysql_select_db("xxxxxxx",$db))
die("No database selected."); 
$acc1="SELECT * from zipcodes where on_off=2 group by groupe_name";
$acc2=mysql_query($acc1) or die("Could not select paused clients.");
while($acc3=mysql_fetch_array($acc2)) {
echo "<a href=\"paused.php?'$acc3[groupe_name]'"\>'$acc3[groupe_name]'</a>"";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/70924-query-db-and-get-results-into-hyperlink/
Share on other sites

Eekkk just cant figure it out, always comes back with a blank page :(

 

<?php
//Paused Clients Query
parse_str("$QUERY_STRING");
$db = mysql_connect("localhost", "xxxx","xxxxxxx") or die("Could not connect.");
if(!$db) 
die("no db");
if(!mysql_select_db("xxxxxxx",$db))
die("No database selected."); 
$acc1="SELECT * from zipcodes where on_off=2 group by groupe_name";
$acc2=mysql_query($acc1) or die("Could not select paused clients.");
while($acc3=mysql_fetch_array($acc2)) {
echo "<a href=\"paused.php?'$acc3[groupe_name]'"\>'$acc3[groupe_name]'</a>"";
}
?>

 

You have several typos in your last line.  If you're echoing an array, you have to use curly brackets.  You're also missing the variable name of the value you're trying to pass via GET (the something I added below).  Try this for your last line, replacing something with what you're actually trying to pass along:

<?php

echo "<a href=\"paused.php?something={$acc3['groupe_name']}\">{$acc3['groupe_name']}</a>";

?>

echo "<a href=\'paused.php?'$acc3[groupe_name]''>'$acc3[groupe_name]'</a>"; // no " allowed in echo!

 

Wrong.  Double-quotes can be put into double-quoted echoes, so long as they're escaped:

<?php

echo "I said \"hello, Mr. Smith\""; //This is okay

?>

Perfect!

 

Ok, now it lists them in hyperlinks is there a way to count how many zips that were in the DB that has the on_off value set to 2 for each of these, and list it behind the hyperlinks for each person?

 

Couldnt we just count the number of times each account shows up? since i am grouping them, i know they atleast have 1 lol

 

thanks again everyone!

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.