PHP - Manipulating A Mysql Resultset
I have a resultset obtained from a MySQL database which contains all the information I want.
I now want to reformat this data, and need some help. My resultset is a list of people's telephone numbers. Most people have more than one number, and at the moment, these appear as separate rows in my resultset, with the person's name repeating on every line. I want to concatenate the telephone numbers so that they appear in a single row with the persons name. So, somehow, I need to check the person_id of each entry, compare it with the last one, etc., etc. What is the best way of doing this ? Thanks for all your help. Similar TutorialsHi, Given below is the output of a field from a mySQL/php query: Product ID: 8457, Product Qty: 3, Product SKU: M-242, Product Name: DCE/DTE DB60 Crossover Cable - 1FT, Product Weight: 1, Product Variation Details: , Product Unit Price: 4.68, Product Total Price: 14.04|Product ID: 8800, Product Qty: 1, Product SKU: M-1038, Product Name: RJ45 8P8C Plug Flat Stranded 50pcs/Bag, Product Weight: 1, Product Variation Details: , Product Unit Price: 3.42, Product Total Price: 3.42|Product ID: 8940, Product Qty: 1, Product SKU: M-1385, Product Name: RJ11/12/45 Crimp Tool with Ratchet [HT-568R], Product Weight: 1, Product Variation Details: , Product Unit Price: 9.89, Product Total Price: 9.89 How can I add a <br> before every occurance of the term "Product" (without quotes). That would make the output legible. Should it be done client side, or server side. I can use help for both. Thanks in advance What I'm basically doing is grabbing data from a source and I want to display it in a different way. A preview of the original data is below: Code: [Select] CODED SURFACE FRONTAL POSITIONS NWS HYDROMETEOROLOGICAL PREDICTION CENTER CAMP SPRINGS MD 626 PM EDT WED NOV 03 2010 VALID 110321Z HIGHS 1022 4120673 1028 6431205 1037 5121174 1022 7090423 1038 4801098 1030 7571450 1022 3471278 1034 4051133 LOWS 993 5320344 966 5391454 997 6230330 999 5240802 1010 3420760 983 6500819 1005 4610855 1006 2940904 OCFNT 2940905 2960901 2980896 2990888 STNRY 3420761 3320775 3250786 3120797 3060803 2990809 2960827 2960845 2980865 3000875 WARM 2990890 3000884 3000874 COLD 2990889 2920886 2860886 2740887 2550890 2300898 2050915 1900925 1790928 TROF 3370890 3230894 3150899 3030905 2960905 OCFNT 5350359 5450351 5510329 5500297 5430258 OCFNT 5381446 5311448 5301459 5351468 5441476 5551479 5631473 5681464 WARM 5681463 5741440 5751407 5641362 COLD 5681464 5651448 5571426 5411395 5101369 4621361 4181372 3911400 WARM 5240803 5260801 5300797 WARM 3420760 3370753 3220744 3110732 COLD 6310816 6070824 5710847 5390887 5260940 5331010 5471037 5701058 STNRY 5691057 5791069 5931103 6061141 6101175 6101228 6211269 6261311 6171372 OCFNT 6480822 6540806 6550778 6500744 6400726 6320724 COLD 6320724 6190730 6010743 5650771 5470785 5300798 WARM 6330724 6200704 5830682 COLD 5240803 5090814 4840835 4740842 4660850 WARM 4600857 4630853 4670849 TROF 5400425 5190425 5030426 COLD 4590856 4510867 4390888 4330920 TROF 4490863 4290871 4110884 TROF 4280784 4190795 4140809 4080821 4050830 3980846 3870859 3780871 TROF 6190558 5990522 5680487 5520465 5480454 TROF 6790829 7110827 7470810 7810750 TROF 4511195 4621185 4751161 4831138 TROF 5891623 6091652 6331660 6571662 6781674 6961718 $$ I will take a few lines from that and explain what I'd like to do. Code: [Select] HIGHS 1022 4120673 1028 6431205 1037 5121174 1022 7090423 1038 4801098 1030 7571450 1022 3471278 1034 4051133 I would like to pull the "1022" (MB) and "4120673" (LAT/LON), then "1028" (MB) and "6431205" (LAT/LON), etc. and display them like this: Code: [Select] Icon: 41.2, -67.3,000,1,1,1022 Icon: 64.3, -120.5,000,1,1,1028 Basically: Icon: LAT, LON,000,1,1,MB "LOWS" would be displayed the same way as "HIGHS" above. "WARM", "COLD", "STNRY", "OCFNT", and "TROF" would be displayed differently as you can see the data for these is different. Those would be displayed like this: From: Code: [Select] COLD 5681464 5651448 5571426 5411395 5101369 4621361 4181372 3911400 To: Code: [Select] Line: 3,0,"Cold Front" 56.8, -146.4 56.5, -144.8 55.7, -142.6 54.1, -139.5 51.0, -136.9 46.2, -136.1 41.8, -137.2 39.1, -140.0 End: For a better understanding of what this data represents you can visit this website. They explain everything nicely. I'm playing around with "explode" at the moment but I'm clueless as the direction to go to achieve all these different things. Any help will be greatly appreciated. What I need is to: - take the information from array 1 - remove it from array 2 - then ADD it OR take from array 3 (this of course depends on array 1) I also have to keep in mind that array 1 could be empty thus needing to empty array 2 and IF the information is in array 3 then remove it array 3 is the main array that I will update the database row which will in turn display the correct check boxes checked or not Thank you for reading, I hope you can help me. Code: [Select] Array //#1 this is the submitted information ( [0] => 103100000 [1] => 103200000 [2] => 103400000 [3] => 103500000 [4] => 103700000 ) Array //#2 all possible choices ( [0] => 103100000 [1] => 103200000 [2] => 103300000 [3] => 103400000 [4] => 103500000 [5] => 103600000 [6] => 103700000 ) Array //#3 currently stored in database / marks the check boxes "checked" ( [0] => 103100000 [1] => 103200000 [2] => 103300000 [3] => 103400000 [4] => 103500000 [5] => 103600000 [6] => 103700000 ) Hi everyone, I am after a scrpit/function that will get information of an uploaded image, resize it, then display the manipulated image. in my "upload" script, there will be a size limit and a file extension/type limit to: 600 x 200px / jpg, gif, jpeg... this is to keep the script i'm after more simple. As using vector images i'm told is such a complicated problem for me at this time. So... to get the size info/dimensions its like this: Code: [Select] <?php list($width, $height, $type, $attr) = getimagesize("image_name.jpg"); echo "Image width " .$width; echo "<BR>"; echo "Image height " .$height; echo "<BR>"; echo "Image type " .$type; echo "<BR>"; echo "Attribute " .$attr; ?> and..... resize something like this: Code: [Select] function get_image_sizes($sourceImageFilePath, $maxResizeWidth, $maxResizeHeight) { // Get width and height of original image $size = getimagesize($sourceImageFilePath); if($size === FALSE) return FALSE; // Error $origWidth = $size[0]; $origHeight = $size[1]; // Change dimensions to fit maximum width and height $resizedWidth = $origWidth; $resizedHeight = $origHeight; if($resizedWidth > $maxResizeWidth) { $aspectRatio = $maxResizeWidth / $resizedWidth; $resizedWidth = round($aspectRatio * $resizedWidth); $resizedHeight = round($aspectRatio * $resizedHeight); } if($resizedHeight > $maxResizeHeight) { $aspectRatio = $maxResizeHeight / $resizedHeight; $resizedWidth = round($aspectRatio * $resizedWidth); $resizedHeight = round($aspectRatio * $resizedHeight); } // Return an array with the original and resized dimensions return array($origWidth, $origHeight, $resizedWidth, $resizedHeight); } // Get dimensions $sizes = get_image_sizes($sourceImageFilePath, $maxResizeWidth, $maxResizeHeight); $origWidth = $sizes[0]; $origHeight = $sizes[1]; $resizedWidth = $sizes[2]; $resizedHeight = $sizes[3]; // Create the resized image $imageOutput = imagecreatetruecolor($resizedWidth, $resizedHeight); if($imageOutput === FALSE) return FALSE; // Error condition // Load the source image $imageSource = imagecreatefromjpeg($sourceImageFilePath); if($imageSource === FALSE) return FALSE; // Error condition $result = imagecopyresampled($imageOutput, $imageSource, 0, 0, 0, 0, $resizedWidth, $resizedHeight, $origWidth, $origHeight); if($result === FALSE) return false; // Error condition // Write out the JPEG file with the highest quality value $result = imagejpeg($imageOutput, $outputPath, 100); if($result === FALSE) return false; // Error condition And.... display is this: Code: [Select] <?php $database="***"; mysql_connect ("***", "***", "***"); @mysql_select_db($database) or die( "Unable to select database"); $result = mysql_query( "SELECT company_name, location, postcode, basicpackage_description, premiumuser_description, upload FROM Companies" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); print "\n\n\nThere are $num_rows records.<P>"; echo "<table><tr><th>Comppany Name</th><th>Location</th><th>Postcode</th><th>Basic Members</th><th>Upgraded Users</th><th>Company Logo</th></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>";// store the records into $row array and loop through while ( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ) { // Print out the contents of the entry echo "<tr><td>{$row['company_name']}</td>"; echo "<td>{$row['location']}</td>"; echo "<td>{$row['postcode']}</td>"; echo "<td>{$row['basicpackage_description']}</td>"; echo "<td>{$row['premiumuser_description']}</td>"; echo "<td><img src=\"http://www.removalspace.com/images/COMPANIES{$row['upload']}\" alt=\"logo\" /></td></tr>";} echo "</table>"; ?> How will all these fit together in one script? any help i'd love it! many thanks in advance trying to create a simpleprogram that will read a text file and output information and calculations using the data in the text file. I have 4 radio buttons which represent an item Number. when one is selected the output form should print to a table the ID,Part,Count, Price, and the inventory Value= ($count * $price), can anyone tell me what i am doing wrong? This is what the .txt file looks like: AC1000:Hammers:122:12.50 AC1001:Wrenches:5:5.00 AC1002:Handsaws:10:10.00 AC1003:Screwdrivers:222:3.00 Here's what i have so far: Code: [Select] <?php $inf = 'infile.txt'; $FILEH = fopen($inf, 'r') or die ("Cannot open $inf"); $inline = fgets($FILEH,4096); $found = 0; //$ptno = //if (isset($_POST['AC1000']) || isset($_POST['AC1000']) || isset($_POST['AC1000']) || isset($_POST['AC1000'])) { while (!feof($FILEH) && !($found)){ list($ptno,$ptname,$num,$price) = split (':', $inline); if ($ptno == $id) { print '<table border=1>'; print '<th> ID <th> Part <th> Count <th> Price'; print "<tr><td> $ptno </td><td>$ptname</td>"; print "<td> $num </td><td> \$price</td><tr>"; print '</table>'; $found = 1; } $inline = fgets($FILEH,4096); } if ($found !=1) { print "Error: PartNo=$id not found"; } fclose ($FILEH); ?> create table mimi (mimiId int(11) not null, mimiBody varchar(255) ); <?php //connecting to database include_once ('conn.php'); $sql ="SELECT mimiId, mimiBody FROM mimi"; $result = mysqli_query($conn, $sql ); $mimi = mysqli_fetch_assoc($result); $mimiId ='<span>No: '.$mimi['mimiId'].'</span>'; $mimiBody ='<p class="leading text-justify">'.$mimi['mimiBody'].'</p>'; ?> //what is next? i want to download pdf or text document after clicking button or link how to do that Hello everyone, Sorry if this has been answered but if it has I can't find it anywhere. So, from the begining then. Lets say I had a member table and in it I wanted to store what their top 3 interests are. Their$ row has all the usual things to identify them userID and password etc.. and I had a further 3 columns which were labled top3_1 top3_2 & top3_3 to put each of their interests in from a post form. If instead I wanted to store this data as a PHP Array instead (using 1 column instead of 3) is there a way to store it as readable data when you open the PHPmyadmin? At the moment all it says is array and when I call it back to the browser (say on a page where they could review and update their interests) it displays 'a' as top3_01 'r' as top3_02 and 'r' as top3_03 (in each putting what would be 'array' as it appears in the table if there were 5 results. Does anyone know what I mean? For example - If we had a form which collected the top 3 interests to put in a table called users, Code: [Select] <form action="back_to_same_page_for_processing.php" method="post" enctype="multipart/form-data"> <input name="top3_01" type="text" value="enter interest number 1 here" /> <input name="top3_02" type="text" value="enter interest number 2 here" /> <input name="top3_03" type="text" value="enter interest number 3 here" /> <input type="submit" name="update_button" value=" Save and Update! " /> </form> // If my quick code example for this form is not correct dont worry its not the point im getting at :) And they put 'bowling' in top3_01, 'running' in top3_02 and 'diving' in top3_03 and we catch that on the same page with some PHP at the top --> Code: [Select] if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' With me so far? If I had a table which had 3 columns (1 for each interest) I could put something like - Code: [Select] include('connect_msql.php'); mysql_query("Select * FROM users WHERE id='$id' AND blah blah blah"); mysql_query("UPDATE users SET top3_01='$top3_01', top3_02='$top3_02', top3_03='$top3_03' WHERE id='$id'"); And hopefully if ive got it right, it will put them each in their own little column. Easy enough huh? But heres the thing, I want to put all these into an array to be stored in the 1 column (say called 'top3') and whats more have them clearly readable in PHPmyadmin and editable from there yet still be able to be called back an rendered on page when requested. Continuing the example then, assuming ive changed the table for the 'top3' column instead of individual colums, I could put something like this - Code: [Select] if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' $top3_array = array($top3_01,$top3_02,$top3_03); include('connect_msql.php'); mysql_query("UPDATE members SET top3='$top3_array' WHERE id='$id' AND blah blah blah"); But it will appear in the column as 'Array' and when its called for using a query it will render the literal string. a r r in each field instead. Now I know you can use the 'serialize()' & 'unserialize()' funtcions but it makes the entry in the database practically unreadable. Is there a way to make it readable and editable without having to create a content management system? If so please let me know and I'll be your friend forever, lol, ok maybe not but I'd really appreciate the help anyways. The other thing is, If you can do this or something like it, how am I to add entries to that array to go back into the data base? I hope ive explained myself enough here, but if not say so and I'll have another go. Thanks very much people, L-PLate (P.s if I sort this out on my own ill post it all here) I have following piece of code below, and I would like to be able to express it pure SQL, something that could go into a .sql file :
$request_string='SELECT topic_forum_id FROM topic_table WHERE topic_id= 2014'; $query=database->prepare($request_string); $query->execute(); $data=$query->fetch(); $query->closeCursor(); $forum=$data['topic_forum_id']; $request_string='INSERT INTO post_table (post_topic,post_forum) VALUES (2014,:forum)'; $query=database->prepare($request_string); $query->bindValue(':forum',$forum,PDO::PARAM_INT); $query->execute(); $data=$query->fetch(); $query->closeCursor();Is it possible ? So i have this php as shown below. It should make a list of comments with comment replies below their comment respectively. The problem is that it only goes through and shows 1 comment and all the comment replies for that one comment. It should be showing all comments i have in the db for that article. If i remove the second while then it shows all the comments correctly but no comment replies then... How do i get this script to loop through the db for every comment but also loop through every comment reply for that $row[id]? If anyone has a better / more efficient way of what I am trying to do, please explain or show example (i am open to anything)... Code: [Select] // what article are we showing? $article_to_show_id = $_GET['article_id']; $active_is_set_text = "1"; // Active Column text that makes it okay to show // Finding the article $search_for_article = mysql_query("SELECT * FROM articles WHERE id = '$article_to_show_id' AND active = '$active_is_set_text'"); while($row = mysql_fetch_array($search_for_article)) { // format the last updated date right $update_date_edit = $row[update_date]; $update_date_edit = date('F j, Y \a\t h:ia', $update_date_edit); $row[update_date] = $update_date_edit; // format the submit updat date right $submit_date_edit = $row[submit_date]; $submit_date_edit = date('F j, Y \a\t h:ia', $submit_date_edit); $row[submit_date] = $submit_date_edit; echo ' <div> ', $row[title] ,' </div> <div> by: ', $row[author] ,' on ', $row[submit_date] ,' </div> <div> ', $row[content] ,' </div> <div> Last Updated: ', $row[update_date] ,' </div> <form action="article_reply.php" method="post"> <input type="hidden" name="article_id" value="', $row[id] ,'" /> <button name="article_reply" type="submit" value="submit">Reply</button> </form> '; } $comment_count = 0; $comment_reply_count = 0; // Finding all of the comments $search_for_article = mysql_query("SELECT * FROM article_comments WHERE article_id = '$article_to_show_id' AND reply_id = '0'"); while($row_comment = mysql_fetch_array($search_for_article)) { // format the submit updat date right $comment_date_edit = $row_comment[comment_date]; $comment_date_edit = date('F j, Y \a\t h:ia', $comment_date_edit); $row_comment[comment_date] = $comment_date_edit; echo ' <br> <br> COMMENT:<br> <div> By: ', $row_comment[username] ,' on ', $row_comment[comment_date] ,' </div> <div> ', $row_comment[comment] ,' </div> '; $comment_count++; // Finding all of the comment replies if any $search_for_article = mysql_query("SELECT * FROM article_comments WHERE article_id = '$article_to_show_id' AND reply_id = '$row_comment[id]'"); while($row_two = mysql_fetch_array($search_for_article)) { // format the submit updat date right $comment_date_edit = $row_two[comment_date]; $comment_date_edit = date('F j, Y \a\t h:ia', $comment_date_edit); $row_two[comment_date] = $comment_date_edit; echo ' <br> <br> COMMENT REPLY:<br> <div> By: ', $row_two[username] ,' on ', $row_two[comment_date] ,' </div> <div> ', $row_two[comment] ,' </div> '; $comment_reply_count++; } } Need some help I have 2 tables in a database and I need to search the first table and use the results from that search, to search another table, can this be done? and if it can how would you recommend that I go about it? Thanks For Your Help Guys! Umm.. Yeah, this MySQL line needs some reviewing list($total_banned_servers) = mysql_fetch_row(mysql_query("SELECT COUNT(id) FROM `toplist` WHERE banned='1' && serverowner=". $_SESSION['user'] ."")); Just want to ask how to create a login system using these wml and php? i have a background on connecting html php and the database.. but in these wml i am confused.. can someone help me? What i'ved got here is Wap Proof for wap emulator to test my codes.. You can download it here http://www.wap-proof.com/ i have tried this code but i gets me to error.. // login.php <?php # Header Info header('Content-Type: text/vnd.wap.wml', true); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); # Version Type print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; # Import config file include "/home/jamieb/private/conf.php"; # Connect to database mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname); ?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <!-- THIS IS THE LOGIN CARD --> <card id="login" title="Login"> <p> <do type="accept" label="Login"> <go href="process.php" method="post"> <postfield name="userName" value="$userName" /> <postfield name="password" value="$password" /> </go> </do> </p> <p> User Name: <input title="userName" name="userName" /> <br /> Password : <input title="password" name="password" type="password" /> <br /> </p> </card> </wml> // process.php <?php # Header Info header('Content-Type: text/vnd.wap.wml', true); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); # Version Type print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; # Import config file include "/home/jamieb/private/conf.php"; # Connect to database mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname); # Verify the user $sql = mysql_query("SELECT userName,nickName FROM table WHERE userName = '".strtolower($_POST['userName'])."' AND password = '".md5($_POST['password'])."'"); $row = mysql_num_rows($sql); $login = mysql_fetch_array($sql); $user = md5($login['userName']); $nick = $login['nickName']; if ($row == 0): ?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="failed" title="Login Failed"> <p> Sorry, username or password incorrect! </p> <p> <anchor>Home <go href="index.php#menu" /> </anchor> <do type="prev" label="Back"><prev/></do></p> </card> </wml> <?php exit; else: ?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="success" title="Login Success"> <p> <do type="accept" label="Admin"> <go href="admin.php" method="post"> <postfield name="session" value="<?php echo "$user"; ?>" /> </go> </do> </p> <p>Welcome <?php echo "$nick"; ?>, please enter the admin area.</p> </card> </wml> <?php endif; ?> My problem here is it doesn't open anything on the wap proof.. or if i ever open it i can't see the submit button.. can someone give some login scripts using php wml? thanks Im trying to compare two different server table and compare match email output. please tell me whats wrong in my code. I have this code I want to check to see if the id from table1 is in table2. Can anyone help me with that if($checkProfile) { $sql_chk_tbl_username = "SELECT id FROM members_profile WHERE id = '"$_SESSION['face']"'"; $rs_user_list = mysql_query($sql_chk_tbl_username); if(mysql_num_rows($rs_user_list) <= 0) } ?> Hello, I am new to this site and hope I am posting this in the right section...
The thing is.....
I would like some help with php and mysql..
What I want to create is a page where users can create an account by entering their name, email and password, and if the username is taken they will have to try again otherwise their details will be registered to the mysql table and have an account to login.
Also I would like a redirect so if the user is a standard user it goes to say “home”, but if the user is an admin it will go to another page ie “home2”, and how would I create the admin in the same table on mysql or seperate?
Right the last thing is once the user can register and login, so can the admin, for instance if there are 10 users, when logged in I want each of those users to see different information can this be done and how could I do this ? I thought maybe have the table and the id would be from 1-10 so if user is 1 being dan show his column, and if user logged 2 being steve show column id 2.
Can somebody help me implement this please ?
I am currently learning php and mysql, im in university I managed to learn how to create the table, connect login, search, add to the database when logged in and edit etc.. but for what I want to achieve now I cannot find any tutorials or help, could somebody please help me with the coding for this and what pages are what and how to create the table in mysql being either 1 table for both user and admin, or 2 tables for separate users and admin.
Thanks for your help in advance guys
Hi all I am am trying to use the following piece of code to import a CSV file into a mySQL database: Code: [Select] $filename = $_FILES['sel_file']['tmp_name']; $handle = fopen($filename, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { mysql_query("INSERT INTO user SET id = '".$userid."', name = '".$data[0]."', email = '".$data[1]."', phone = '".$data[2]."'") or die(mysql_error()); } fclose($handle); It works great except it only imports one line in the CSV file. How do I get it to keep adding the lines into the DB? My CSV looks like this: Pete Naylor,test@mail.com,0800101101 Bob Jones,bob@mail.com,08700123123 Many thanks for for help Pete I am having issues in writing a program. The basic idea is a internet radio website. I have a page listing all shows on the station with a brief description. When you click on a specific show from that page, i need it to open a page showing more detail on just that show. The show list page is loading with no problem, but the show detail pages keep coming up with "Error in your sql syntax at line 1" See what I have at http://www.eliteweboffers.com/lwrs/shows.php Here is the code from config.php Code: [Select] <?php mysql_connect($host,$user,$password); mysql_select_db($db); //Functions function show_list() { $query = "SELECT * FROM shows"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo " <table border='0'> <tr> <td rowspan='2'> <a href='". $site ."show_page.php?". $row['id'] ."' name='show_id' value='". $row['id'] ."'> <img src='". $site,$row['picture'] ."' height='180' width='180'></img></a> </td> <td> " . $row['show'] . " </td> </tr> <tr> <td> " . $row['description-short'] . " </td> </tr> </table> ";} } function show_page() { $show_id=$_POST[show_id]; $query = "SELECT * FROM shows WHERE id = $show_id"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo " <table border='0'> <tr> <td rowspan='2'> <img src='". $site,$row['picture'] ."' height='180' width='180'></img> </td> <td> " . $row['show'] . " </td> </tr> <tr> <td> " . $row['description-short'] . " </td> </tr> </table> ";} } ?> If i change the line Code: [Select] $show_id=$_POST[show_id];to Code: [Select] $show_id=1; It loads the show detail page properly for the first show. I don't want to have to use "if" statements for every single show id. What am I doing wrong ? Can anyone help ??? Here is the code from shows.php Code: [Select] <?php include ('/home/ansonb/lwr_config.php'); show_list(); ?> Here is the code from show_page.php Code: [Select] <?php include ('/home/ansonb/lwr_config.php'); show_page(); ?> Any help would be greatly appreciated. Thank you ! is it true ? in paging 0,92,085,0,50,066,0,73 etc its coming to mixing Quote $en_cokk = mysql_query("select baslik,baslik_seo , liked/(liked+hate) avg from hikayeler order by avg DESC limit 10"); there are two row in database liked and hate; how can i take average and sort desc to page from database ? |