PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old March 1st, 2002, 08:29 PM
flying23x flying23x is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 flying23x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
php mysql help

I was wondering if any one could help me. I am have a database with php and mysql, and it outputs the information on a search. How can I get it to output a link to that specific page of the search results. SO, if you search for cars, it would make a link to that page. http://www.test.com/cars.php

Reply With Quote
  #2  
Old March 1st, 2002, 08:37 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 23 sec
Reputation Power: 6
RE: php mysql help

You are going to need to be a little for specific. Do you already have the info in your database? How is it stored? Are you saying that you already have a functioning search, but it only shows the data and you want it to have a link instead?


Reply With Quote
  #3  
Old March 8th, 2002, 09:35 PM
webxdevelopment webxdevelopment is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 webxdevelopment User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: php mysql help

Hey flying what about somthing like this (without any details it is very hard to help)

$result= mysql_query("select * from cars");
if (!$result) {
echo("</TABLE>");
echo("<P>Error retrieving cars from database!<BR>".
"Error: " . mysql_error());
exit();
}
echo "<center><table>n";
while ($r = mysql_fetch_array($result)) {

if ($bgcolor == "bgcolor = #C0C0C0") {
$bgcolor = "bgcolor = #FFFFFF";
} else {
$bgcolor = "bgcolor = #C0C0C0";
}
echo("<TR>n");
$Car_link = $r["Car_link"];

$Car_name = $r["Car_name"];

echo("<td $bgcolor><center><font color=#0033af><a href='" . $r["Car_link"] . "'>" . $r["Car_name"] ."</td>n");
echo("</tr>n");
}
echo "</center></table>n";

Reply With Quote
  #4  
Old April 10th, 2002, 07:47 AM
Gore Gore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 Gore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: php mysql help

Hey guys, Im new to this place AND php. I have a similar question. I have set up a page to put data from mySQL in to tables (got the info from this site). I want the data in "item_num" to be a link going to a page with the corresponding item_num.html.

Example Output:

2314 | Ring | Gold Ring

I want the "2314" to link to a page 2314.html. Here is what I have so far....

<?PHP
$db = mysql_connect("localhost","$login","$password") or die("Problem connecting");
mysql_select_db("jewelryboxnw_com") or die("Problem selecting database");
$query = "SELECT * FROM inventory ORDER BY item_num";
$result = mysql_query($query) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
?>

<html>

<head><title></title></head>

<body>

<?PHP
echo "<TABLE BORDER="0">n";
echo "<TR bgcolor="lightblue"><TD>Item#</TD><TD>Price</TD><TD>Item</TD><TD>Description</TD></TR>n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor="#FFFFCC">n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor="white">n";
}
echo "<TD>".$row['item_num']."</TD><TD>".$row['price']."</TD><TD>".$row['item']."</TD><TD>".$row['desc']."</TD>n";
echo "</TR>n";
}
//now let's close the table and be done with it
echo "</TABLE>n";
?>

</body>

</html>


....the code here probably looks crappy and I am open to ANY suggestions!

Thanks!

Reply With Quote
  #5  
Old April 10th, 2002, 09:57 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 23 sec
Reputation Power: 6
RE: php mysql help

All you need to do is take this one line :

echo "<TD>".$row['item_num']."</TD><TD>".$row['price']."</TD><TD>".$row['item']."</TD><TD>".$row['desc']."</TD>n";


and change it to something like this : (I have made it two seperate line now just because I find it easier to read):

echo "<TD><a href="".$row['item_num'].".html">".$row['item_num']."</a></TD>";
echo "<TD>".$row['price']."</TD><TD>".$row['item']."</TD><TD>".$row['desc']."</TD>n";

Hope that helps...

Reply With Quote
  #6  
Old April 11th, 2002, 02:38 AM
Gore Gore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 Gore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: php mysql help

Thanks Matt! That helps a lot. I'll try it out tonight.

Reply With Quote
  #7  
Old April 11th, 2002, 02:47 AM
Gore Gore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 Gore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: php mysql help

Woohoo! It works perfect! Thank you!

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > php mysql help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway